hacktons / convex_bottom_bar

A Flutter package which implements a ConvexAppBar to show a convex tab in the bottom bar. Theming supported.
https://bar.hacktons.cn
Apache License 2.0
791 stars 147 forks source link

Another exception was thrown: DefaultTabController.of() #183

Closed jobindcruz closed 1 year ago

jobindcruz commented 1 year ago

Notice for Stack compile error

* Another exception was thrown: DefaultTabController.of() was called with a context that does not contain a DefaultTabController widget.
I/flutter (  485): Another exception was thrown: Invalid argument(s): NaN

Please search the issue list and FAQ list before opening any issues!!

Environment details

flutter doctor
[✓] Flutter (Channel master, 3.5.0-12.0.pre.130, on macOS 13.0 22A380 darwin-arm64 (Rosetta), locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio
[✓] VS Code (version 1.73.0)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

flutter --version
Flutter 3.5.0-12.0.pre.130 • channel master • https://github.com/flutter/flutter.git
Framework • revision 06ded49f7a (7 hours ago) • 2022-11-04 23:30:55 -0400
Engine • revision cf56eb5565
Tools • Dart 2.19.0 (build 2.19.0-374.0.dev) • DevTools 2.19.0

Paste the package version.

dependencies:
  convex_bottom_bar: 3.1.0+1

Sample Code

bottomNavigationBar: ConvexAppBar(
        items: const [
          TabItem(icon: Icons.list),
          TabItem(icon: Icons.calendar_today),
          TabItem(icon: Icons.assessment),
        ],
        initialActiveIndex: 1,
        onTap: (int i) => print('click index=$i'),
),

Screenshots

WhatsApp Image 2022-11-05 at 4 11 19 PM

jobindcruz commented 1 year ago

The issue is solved, i added this line of code

disableDefaultTabController: true,


ConvexAppBar(
        disableDefaultTabController: true,
        items: const [
          TabItem(icon: Icons.list),
          TabItem(icon: Icons.calendar_today),
          TabItem(icon: Icons.assessment),
        ],
        initialActiveIndex: 1,
        onTap: (int i) => print('click index=$i'),
 )