Skip to content

Commit 4f2e321

Browse files
authored
fix a tabs indicator padding update bug (#108287)
1 parent 07de84f commit 4f2e321

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

packages/flutter/lib/src/material/tabs.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,7 @@ class _TabBarState extends State<TabBar> {
10241024
} else if (widget.indicatorColor != oldWidget.indicatorColor ||
10251025
widget.indicatorWeight != oldWidget.indicatorWeight ||
10261026
widget.indicatorSize != oldWidget.indicatorSize ||
1027+
widget.indicatorPadding != oldWidget.indicatorPadding ||
10271028
widget.indicator != oldWidget.indicator) {
10281029
_initIndicatorPainter();
10291030
}

packages/flutter/test/material/tabs_test.dart

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,35 @@ void main() {
238238
debugResetSemanticsIdCounter();
239239
});
240240

241+
testWidgets('indicatorPadding update test', (WidgetTester tester) async {
242+
// Regressing test for https://github.com/flutter/flutter/issues/108102
243+
const Tab tab = Tab(text: 'A');
244+
const EdgeInsets indicatorPadding = EdgeInsets.only(left: 7.0, right: 7.0);
245+
246+
await tester.pumpWidget(boilerplate(
247+
child: const DefaultTabController(
248+
length: 1,
249+
child: TabBar(
250+
tabs: <Tab>[tab],
251+
indicatorPadding: indicatorPadding,
252+
),
253+
),
254+
));
255+
256+
// Change the indicatorPadding
257+
await tester.pumpWidget(boilerplate(
258+
child: DefaultTabController(
259+
length: 1,
260+
child: TabBar(
261+
tabs: const <Tab>[tab],
262+
indicatorPadding: indicatorPadding + const EdgeInsets.all(7.0),
263+
),
264+
),
265+
), Duration.zero, EnginePhase.build);
266+
267+
expect(tester.renderObject(find.byType(CustomPaint)).debugNeedsPaint, true);
268+
});
269+
241270
testWidgets('Tab sizing - icon', (WidgetTester tester) async {
242271
await tester.pumpWidget(
243272
const MaterialApp(home: Center(child: Material(child: Tab(icon: SizedBox(width: 10.0, height: 10.0))))),

0 commit comments

Comments
 (0)