add assert if length of TabController and number of tabs do not match (#29332)
This commit is contained in:
@@ -778,6 +778,17 @@ class _TabBarState extends State<TabBar> {
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
|
||||
assert(() {
|
||||
if (newController.length != widget.tabs.length) {
|
||||
throw FlutterError(
|
||||
'Controller\'s length property (${newController.length}) does not match the \n'
|
||||
'number of tab elements (${widget.tabs.length}) present in TabBar\'s tabs property.'
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
|
||||
if (newController == _controller)
|
||||
return;
|
||||
|
||||
@@ -1122,6 +1133,17 @@ class _TabBarViewState extends State<TabBarView> {
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
|
||||
assert(() {
|
||||
if (newController.length != widget.children.length) {
|
||||
throw FlutterError(
|
||||
'Controller\'s length property (${newController.length}) does not match the \n'
|
||||
'number of elements (${widget.children.length}) present in TabBarView\'s children property.'
|
||||
);
|
||||
}
|
||||
return true;
|
||||
}());
|
||||
|
||||
if (newController == _controller)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user