@@ -3646,6 +3646,101 @@ void main() {
36463646 );
36473647 });
36483648
3649+ testWidgets ('TabBar accepts indicatorWeight: 0 when the indicator comes from TabBarThemeData' , (
3650+ WidgetTester tester,
3651+ ) async {
3652+ // Regression test for https://github.com/flutter/flutter/issues/188837.
3653+ // A themed indicator supplies the decoration, so indicatorWeight: 0 must not
3654+ // trip the default-underline assertion.
3655+ const indicatorColor = Color (0xFF00FF00 );
3656+ const Decoration indicator = BoxDecoration (color: indicatorColor);
3657+ const tabs = < Widget > [Tab (text: 'A' ), Tab (text: 'B' )];
3658+
3659+ Widget buildFrame ({required bool secondary}) {
3660+ return boilerplate (
3661+ useMaterial3: false ,
3662+ tabBarTheme: const TabBarThemeData (
3663+ indicator: indicator,
3664+ indicatorSize: TabBarIndicatorSize .tab,
3665+ ),
3666+ child: Container (
3667+ alignment: Alignment .topLeft,
3668+ child: DefaultTabController (
3669+ length: tabs.length,
3670+ child: secondary
3671+ ? TabBar .secondary (indicatorWeight: 0.0 , tabs: tabs)
3672+ : TabBar (indicatorWeight: 0.0 , tabs: tabs),
3673+ ),
3674+ ),
3675+ );
3676+ }
3677+
3678+ // Primary TabBar: no assertion is thrown and the themed indicator is painted.
3679+ await tester.pumpWidget (buildFrame (secondary: false ));
3680+ expect (tester.takeException (), isNull);
3681+
3682+ final RenderBox tabBarBox = tester.firstRenderObject <RenderBox >(find.byType (TabBar ));
3683+ // 46 = _kTabHeight(46) with no weight added by the zero indicatorWeight.
3684+ expect (tabBarBox.size.height, 46.0 );
3685+ expect (
3686+ tabBarBox,
3687+ paints..rect (rect: const Rect .fromLTRB (0.0 , 0.0 , 400.0 , 46.0 ), color: indicatorColor),
3688+ );
3689+
3690+ // Secondary TabBar: also accepts a zero indicatorWeight with a themed indicator.
3691+ await tester.pumpWidget (buildFrame (secondary: true ));
3692+ expect (tester.takeException (), isNull);
3693+ });
3694+
3695+ testWidgets ('TabBar accepts indicatorWeight: 0 when the indicator is provided on the widget' , (
3696+ WidgetTester tester,
3697+ ) async {
3698+ const Decoration indicator = BoxDecoration (color: Color (0xFF00FF00 ));
3699+ const tabs = < Widget > [Tab (text: 'A' ), Tab (text: 'B' )];
3700+
3701+ await tester.pumpWidget (
3702+ boilerplate (
3703+ useMaterial3: false ,
3704+ child: DefaultTabController (
3705+ length: tabs.length,
3706+ child: const TabBar (indicator: indicator, indicatorWeight: 0.0 , tabs: tabs),
3707+ ),
3708+ ),
3709+ );
3710+
3711+ expect (tester.takeException (), isNull);
3712+ });
3713+
3714+ testWidgets ('TabBar asserts indicatorWeight: 0 with the default underline indicator' , (
3715+ WidgetTester tester,
3716+ ) async {
3717+ // With no indicator on the widget or the theme, the TabBar falls back to the
3718+ // default underline indicator, which requires a positive indicatorWeight.
3719+ const tabs = < Widget > [Tab (text: 'A' ), Tab (text: 'B' )];
3720+
3721+ await tester.pumpWidget (
3722+ boilerplate (
3723+ useMaterial3: false ,
3724+ child: DefaultTabController (
3725+ length: tabs.length,
3726+ child: TabBar (indicatorWeight: 0.0 , tabs: tabs),
3727+ ),
3728+ ),
3729+ );
3730+ expect (tester.takeException (), isAssertionError);
3731+
3732+ await tester.pumpWidget (
3733+ boilerplate (
3734+ useMaterial3: false ,
3735+ child: DefaultTabController (
3736+ length: tabs.length,
3737+ child: TabBar .secondary (indicatorWeight: 0.0 , tabs: tabs),
3738+ ),
3739+ ),
3740+ );
3741+ expect (tester.takeException (), isAssertionError);
3742+ });
3743+
36493744 testWidgets ('TabBar with custom indicator - directional indicatorPadding (LTR)' , (
36503745 WidgetTester tester,
36513746 ) async {
0 commit comments