From 4f2e32173f3e284365065adf1d4b26adf26c331c Mon Sep 17 00:00:00 2001 From: xubaolin Date: Thu, 28 Jul 2022 08:49:05 +0800 Subject: [PATCH] fix a tabs indicator padding update bug (#108287) --- packages/flutter/lib/src/material/tabs.dart | 1 + packages/flutter/test/material/tabs_test.dart | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index 10daa6af48..d1f16219cd 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -1024,6 +1024,7 @@ class _TabBarState extends State { } else if (widget.indicatorColor != oldWidget.indicatorColor || widget.indicatorWeight != oldWidget.indicatorWeight || widget.indicatorSize != oldWidget.indicatorSize || + widget.indicatorPadding != oldWidget.indicatorPadding || widget.indicator != oldWidget.indicator) { _initIndicatorPainter(); } diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index a8cd7e3d09..473ccdf467 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -238,6 +238,35 @@ void main() { debugResetSemanticsIdCounter(); }); + testWidgets('indicatorPadding update test', (WidgetTester tester) async { + // Regressing test for https://github.com/flutter/flutter/issues/108102 + const Tab tab = Tab(text: 'A'); + const EdgeInsets indicatorPadding = EdgeInsets.only(left: 7.0, right: 7.0); + + await tester.pumpWidget(boilerplate( + child: const DefaultTabController( + length: 1, + child: TabBar( + tabs: [tab], + indicatorPadding: indicatorPadding, + ), + ), + )); + + // Change the indicatorPadding + await tester.pumpWidget(boilerplate( + child: DefaultTabController( + length: 1, + child: TabBar( + tabs: const [tab], + indicatorPadding: indicatorPadding + const EdgeInsets.all(7.0), + ), + ), + ), Duration.zero, EnginePhase.build); + + expect(tester.renderObject(find.byType(CustomPaint)).debugNeedsPaint, true); + }); + testWidgets('Tab sizing - icon', (WidgetTester tester) async { await tester.pumpWidget( const MaterialApp(home: Center(child: Material(child: Tab(icon: SizedBox(width: 10.0, height: 10.0))))),