Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extendBodyBehindAppBar confuses defaultTabController #88315

Open
sobrienpdx opened this issue Aug 16, 2021 · 5 comments
Open

extendBodyBehindAppBar confuses defaultTabController #88315

sobrienpdx opened this issue Aug 16, 2021 · 5 comments
Labels
a: error message Error messages from the Flutter framework f: material design flutter/packages/flutter/material repository. found in release: 2.2 Found to occur in 2.2 found in release: 2.5 Found to occur in 2.5 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on team-design Owned by Design Languages team triaged-design Triaged by Design Languages team

Comments

@sobrienpdx
Copy link

sobrienpdx commented Aug 16, 2021

I have a defaultTabController that programmatically determines it's length. The scaffold that contains the defaultTabController has an app bar. When the app bar has extendBodyBehindAppBar = true the defaultTabController gets confused and gives me this error message:

The following assertion was thrown building TabBar(dirty, dependencies: [_LocalizationsScope-[GlobalKey#336ca], _InheritedTheme, _TabControllerScope], state: _TabBarState#6dd4e):
Controller's length property (2) does not match the number of tabs (3) present in TabBar's tabs property.

When the exception was thrown, this was the stack: 
#0      _TabBarState.build.<anonymous closure> (package:flutter/src/material/tabs.dart:1147:9)
#1      _TabBarState.build (package:flutter/src/material/tabs.dart:1153:6)
#2      StatefulElement.build (package:flutter/src/widgets/framework.dart:4612:27)
#3      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4495:15)
#4      StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4667:11)

If I directly print defaultTabController.length and number of tabs they seem fine. Also the program seems to be working fine... ?

@darshankawar darshankawar added the in triage Presently being triaged by the triage team label Aug 17, 2021
@darshankawar
Copy link
Member

@sobrienpdx
Can you provide flutter doctor -v and a complete reproducible code sample that we can use that shows this behavior ?
Thanks.

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Aug 17, 2021
@sobrienpdx
Copy link
Author

@darshankawar yes, please find a repro here: https://github.com/sobrienpdx/repro_tabController_bug

If you comment out extendBodyBehindAppBar = true it works great, but otherwise it gives you errors

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Aug 25, 2021
@darshankawar
Copy link
Member

@sobrienpdx
Thanks for the repo, although I see that you are using below 3rd party plugins in it:

flutter_mobx: ^2.0.0
  mobx: ^2.0.1
  provider: ^5.0.0

Does the behavior persist without using any of above plugin code ? If so, could you update the repo and provide only the core code with which the issue persist ?
Thanks.

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Aug 25, 2021
@sobrienpdx
Copy link
Author

@darshankawar
It is still a bug without Mobx, which I have removed. I don't know if it's related to Provider, and unfortunately I am unable to spend any additional time on this (I'm a small business owner and have my own deadlines to meet!). The repro I made for you is <100 lines of code, and I really hope that is enough to help you get a fix for this.

Thanks so much!

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Aug 25, 2021
@darshankawar
Copy link
Member

Thanks @sobrienpdx for the updated code sample. I see the same behavior on latest master and stable.

  1. With extendBodyBehindAppBar: true commented out, see the tabs getting added properly:

Screenshot 2021-08-26 at 10 28 59 AM

  1. With extendBodyBehindAppBar: true and trying to add more tabs, get the following exception:
console error log
======== Exception caught by widgets library =======================================================
The following assertion was thrown building TabBar(dirty, dependencies: [_InheritedTheme, _TabControllerScope, _LocalizationsScope-[GlobalKey#1207c]], state: _TabBarState#cece1):
Controller's length property (4) does not match the number of tabs (3) present in TabBar's tabs property.

The relevant error-causing widget was: 
  TabBar TabBar:file:///Users/dhs/Documents/NCFlutter/bug_test/lib/main.dart:90:12
When the exception was thrown, this was the stack: 
#0      _TabBarState.build.<anonymous closure> (package:flutter/src/material/tabs.dart:1108:9)
#1      _TabBarState.build (package:flutter/src/material/tabs.dart:1114:6)
#2      StatefulElement.build (package:flutter/src/widgets/framework.dart:4712:27)
#3      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4595:15)
#4      StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4770:11)
#5      Element.rebuild (package:flutter/src/widgets/framework.dart:4313:5)
#6      BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2578:33)
#7      WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:882:21)
#8      RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:319:5)
#9      SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1143:15)
#10     SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1080:9)
#11     SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:996:5)
#15     _invoke (dart:ui/hooks.dart:166:10)
#16     PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:270:5)
#17     _drawFrame (dart:ui/hooks.dart:129:31)
(elided 3 frames from dart:async)
====================================================================================================


stable and master flutter doctor -v
[✓] Flutter (Channel stable, 2.2.3, on Mac OS X 10.15.4 19E2269 darwin-x64,
    locale en-GB)
    • Flutter version 2.2.3 at /Users/dhs/documents/fluttersdk/flutter
    • Framework revision f4abaa0735 (4 days ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30)
    • Android SDK at /Users/dhs/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = /Users/dhs/Library/Android/sdk
    • Java binary at: /Users/dhs/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7486908/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.    

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.3, Build version 12C33
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Users/dhs/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7486908/Android
      Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)        

[✓] VS Code (version 1.57.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (4 available)
    • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 10 (API 29)
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                               •
      web-javascript • Google Chrome 91.0.4472.114

• No issues found!

[✓] Flutter (Channel master, 2.5.0-7.0.pre.228, on Mac OS X 10.15.4 19E2269
    darwin-x64, locale en-GB)
    • Flutter version 2.5.0-7.0.pre.228 at
      /Users/dhs/documents/fluttersdk/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ac05e7e3fe (3 hours ago), 2021-08-25 00:41:06 -0400
    • Engine revision a9efb963de
    • Dart version 2.15.0 (build 2.15.0-43.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30)
    • Android SDK at /Users/dhs/Library/Android/sdk
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = /Users/dhs/Library/Android/sdk
    • Java binary at: /Users/dhs/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7486908/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.    

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5.1, Build version 12E507
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Users/dhs/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/202.7486908/Android
      Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)        

[✓] VS Code (version 1.57.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.21.0

[✓] Connected device (4 available)
    • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 10 (API 29)
    • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
    • macOS (desktop)            • macos                                •
      darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
    • Chrome (web)               • chrome                               •
      web-javascript • Google Chrome 91.0.4472.114






@darshankawar darshankawar added f: material design flutter/packages/flutter/material repository. found in release: 2.2 Found to occur in 2.2 found in release: 2.5 Found to occur in 2.5 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on a: error message Error messages from the Flutter framework and removed in triage Presently being triaged by the triage team labels Aug 26, 2021
@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-design Owned by Design Languages team triaged-design Triaged by Design Languages team labels Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: error message Error messages from the Flutter framework f: material design flutter/packages/flutter/material repository. found in release: 2.2 Found to occur in 2.2 found in release: 2.5 Found to occur in 2.5 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on team-design Owned by Design Languages team triaged-design Triaged by Design Languages team
Projects
None yet
Development

No branches or pull requests

3 participants