@@ -127,17 +127,19 @@ class _GFTabBarViewState extends State<GFTabBarView> {
127127 }
128128
129129 void _handleTabControllerAnimationTick () {
130- if (_warpUnderwayCount > 0 || ! _controller! .indexIsChanging) {
131- return ;
132- } // This widget is driving the controller's animation.
133- if (_controller! .index != _currentIndex) {
134- _currentIndex = _controller! .index;
135- _warpToCurrentIndex ();
130+ if (_controller != null ) {
131+ if (_warpUnderwayCount > 0 || ! _controller! .indexIsChanging) {
132+ return ;
133+ } // This widget is driving the controller's animation.
134+ if (_controller! .index != _currentIndex) {
135+ _currentIndex = _controller! .index;
136+ _warpToCurrentIndex ();
137+ }
136138 }
137139 }
138140
139141 Future <void > _warpToCurrentIndex () async {
140- if (! mounted) {
142+ if (! mounted || _pageController == null || _currentIndex == null ) {
141143 return Future <void >.value ();
142144 }
143145
@@ -188,6 +190,12 @@ class _GFTabBarViewState extends State<GFTabBarView> {
188190 if (notification.depth != 0 ) {
189191 return false ;
190192 }
193+ if (_controller == null ||
194+ _pageController == null ||
195+ _pageController? .page != null ||
196+ _controller? .index == null ) {
197+ return false ;
198+ }
191199
192200 _warpUnderwayCount += 1 ;
193201 if (notification is ScrollUpdateNotification &&
@@ -209,9 +217,9 @@ class _GFTabBarViewState extends State<GFTabBarView> {
209217 @override
210218 Widget build (BuildContext context) {
211219 assert (() {
212- if (_controller! .length != widget.children.length) {
220+ if (_controller? .length != widget.children.length) {
213221 throw FlutterError (
214- 'Controller\' s length property (${_controller ! .length }) does not match the \n '
222+ 'Controller\' s length property (${_controller ? .length }) does not match the \n '
215223 'number of tabs (${widget .children .length }) present in TabBar\' s tabs property.' );
216224 }
217225 return true ;
0 commit comments