Unverified Commit 156c6614 authored by codiss's avatar codiss Committed by GitHub

Fix Material3 TabBarTheme.dividerColor not working (#119690)

* Fixed Material3 TabBarTheme.dividerColor not working

* Add 'Material3 - TabBar inherits the dividerColor of TabBarTheme' test

---------
Co-authored-by: 's avatarKate Lovett <katelovett@google.com>
parent 4ef1fe44
......@@ -1122,7 +1122,7 @@ class _TabBarState extends State<TabBar> {
indicatorPadding: widget.indicatorPadding,
tabKeys: _tabKeys,
old: _indicatorPainter,
dividerColor: theme.useMaterial3 ? widget.dividerColor ?? defaults.dividerColor : null,
dividerColor: theme.useMaterial3 ? widget.dividerColor ?? tabBarTheme.dividerColor ?? defaults.dividerColor : null,
labelPaddings: _labelPaddings,
);
}
......
......@@ -5614,6 +5614,36 @@ void main() {
labelColor.withAlpha(0xB2) // 70% alpha,
);
});
testWidgets('Material3 - TabBar inherits the dividerColor of TabBarTheme', (WidgetTester tester) async {
const Color dividerColor = Colors.yellow;
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(
useMaterial3: true,
tabBarTheme: const TabBarTheme(dividerColor: dividerColor),
),
home: Scaffold(
appBar: AppBar(
bottom: TabBar(
controller: TabController(length: 3, vsync: const TestVSync()),
tabs: const <Widget>[
Tab(text: 'Tab 1'),
Tab(text: 'Tab 2'),
Tab(text: 'Tab 3'),
],
),
),
),
),
);
// Test painter's divider color.
final CustomPaint paint = tester.widget<CustomPaint>(find.byType(CustomPaint).last);
// ignore: avoid_dynamic_calls
expect((paint.painter as dynamic).dividerColor, dividerColor);
});
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment