-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: error messageError messages from the Flutter frameworkError messages from the Flutter frameworkf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.24Found to occur in 3.24Found to occur in 3.24found in release: 3.25Found to occur in 3.25Found to occur in 3.25frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
Steps to reproduce
- Run example codes.
- Tap the top button to add a tab.
Expected results
No crash.
Actual results
Crashed.
Code sample
Code sample
import 'package:flutter/material.dart';
void main() {
final List<String> tabs = <String>[];
runApp(MaterialApp(
home: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return DefaultTabController(
length: tabs.length,
child: Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
actions: <Widget>[
TextButton(
child: const Text('Add Tab'),
onPressed: () {
setState(() {
tabs.add('Tab ${tabs.length + 1}');
});
},
),
],
bottom: TabBar(
tabs: tabs.map((String tab) => Tab(text: tab)).toList(),
),
),
],
),
),
);
},
),
));
}Screenshots or Video
No response
Logs
Logs
======== Exception caught by widgets library =======================================================
The following RangeError was thrown building TabBar(dirty, dependencies: [InheritedCupertinoTheme, MediaQuery, _InheritedTheme, _LocalizationsScope-[GlobalKey#270e5], _TabControllerScope], state: _TabBarState#b7c42):
RangeError (length): Invalid value: Valid value range is empty: 0
The relevant error-causing widget was:
Column Column:file:///D:/flutter_master/packages/flutter/lib/src/material/app_bar.dart:1086:16
When the exception was thrown, this was the stack:
#0 List.[] (dart:core-patch/growable_array.dart)
#1 _TabBarState.build (package:flutter/src/material/tabs.dart:1748:62)
#2 StatefulElement.build (package:flutter/src/widgets/framework.dart:5749:27)
#3 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5637:15)
#4 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5800:11)
#5 Element.rebuild (package:flutter/src/widgets/framework.dart:5353:7)
#6 BuildScope._tryRebuild (package:flutter/src/widgets/framework.dart:2701:15)
#7 BuildScope._flushDirtyElements (package:flutter/src/widgets/framework.dart:2760:11)
#8 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:3056:18)
#9 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:1176:21)
#10 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:475:5)
#11 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1397:15)
#12 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1318:9)
#13 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1176:5)
#14 _invoke (dart:ui/hooks.dart:312:13)
#15 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:419:5)
#16 _drawFrame (dart:ui/hooks.dart:283:31)
====================================================================================================Flutter Doctor output
Doctor output
[√] Flutter (Channel master, 3.25.0-1.0.pre.219, on Microsoft Windows [版本 10.0.19045.4651], locale zh-CN)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.9.6)
[√] Android Studio (version 2022.2)
[√] Android Studio (version 2024.1)
[√] IntelliJ IDEA Ultimate Edition (version 2023.3)
[√] VS Code, 64-bit edition (version 1.76.2)
[√] Connected device (3 available)
[√] Network resources
• No issues found!Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: error messageError messages from the Flutter frameworkError messages from the Flutter frameworkf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.24Found to occur in 3.24Found to occur in 3.24found in release: 3.25Found to occur in 3.25Found to occur in 3.25frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team