mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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: Kate Lovett <katelovett@google.com>
This commit is contained in:
parent
4ef1fe4434
commit
156c6614bf
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user