Unverified Commit 2a21c1a1 authored by Shi-Hao Hong's avatar Shi-Hao Hong Committed by GitHub

add assert if length of TabController and number of tabs do not match (#29332)

parent 87e6beec
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment