Removed accentColor dependency from ExpansionTile (#77933)
This commit is contained in:
parent
5344ed7156
commit
82f1d639e0
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
import 'color_scheme.dart';
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
import 'list_tile.dart';
|
import 'list_tile.dart';
|
||||||
@ -289,13 +290,14 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
|
|||||||
@override
|
@override
|
||||||
void didChangeDependencies() {
|
void didChangeDependencies() {
|
||||||
final ThemeData theme = Theme.of(context);
|
final ThemeData theme = Theme.of(context);
|
||||||
|
final ColorScheme colorScheme = theme.colorScheme;
|
||||||
_borderColorTween.end = theme.dividerColor;
|
_borderColorTween.end = theme.dividerColor;
|
||||||
_headerColorTween
|
_headerColorTween
|
||||||
..begin = widget.collapsedTextColor ?? theme.textTheme.subtitle1!.color
|
..begin = widget.collapsedTextColor ?? theme.textTheme.subtitle1!.color
|
||||||
..end = widget.textColor ?? theme.accentColor;
|
..end = widget.textColor ?? colorScheme.secondary;
|
||||||
_iconColorTween
|
_iconColorTween
|
||||||
..begin = widget.collapsedIconColor ?? theme.unselectedWidgetColor
|
..begin = widget.collapsedIconColor ?? theme.unselectedWidgetColor
|
||||||
..end = widget.iconColor ?? theme.accentColor;
|
..end = widget.iconColor ?? colorScheme.secondary;
|
||||||
_backgroundColorTween
|
_backgroundColorTween
|
||||||
..begin = widget.collapsedBackgroundColor
|
..begin = widget.collapsedBackgroundColor
|
||||||
..end = widget.backgroundColor;
|
..end = widget.backgroundColor;
|
||||||
|
@ -43,7 +43,7 @@ class TestTextState extends State<TestText> {
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
const Color _dividerColor = Color(0x1f333333);
|
const Color _dividerColor = Color(0x1f333333);
|
||||||
const Color _accentColor = Colors.blueAccent;
|
const Color _foregroundColor = Colors.blueAccent;
|
||||||
const Color _unselectedWidgetColor = Colors.black54;
|
const Color _unselectedWidgetColor = Colors.black54;
|
||||||
const Color _headerColor = Colors.black45;
|
const Color _headerColor = Colors.black45;
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ void main() {
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
accentColor: _accentColor,
|
colorScheme: ColorScheme.fromSwatch().copyWith(secondary: _foregroundColor),
|
||||||
unselectedWidgetColor: _unselectedWidgetColor,
|
unselectedWidgetColor: _unselectedWidgetColor,
|
||||||
textTheme: const TextTheme(subtitle1: TextStyle(color: _headerColor)),
|
textTheme: const TextTheme(subtitle1: TextStyle(color: _headerColor)),
|
||||||
),
|
),
|
||||||
@ -195,9 +195,9 @@ void main() {
|
|||||||
Color iconColor(Key key) => tester.state<TestIconState>(find.byKey(key)).iconTheme.color!;
|
Color iconColor(Key key) => tester.state<TestIconState>(find.byKey(key)).iconTheme.color!;
|
||||||
Color textColor(Key key) => tester.state<TestTextState>(find.byKey(key)).textStyle.color!;
|
Color textColor(Key key) => tester.state<TestTextState>(find.byKey(key)).textStyle.color!;
|
||||||
|
|
||||||
expect(textColor(expandedTitleKey), _accentColor);
|
expect(textColor(expandedTitleKey), _foregroundColor);
|
||||||
expect(textColor(collapsedTitleKey), _headerColor);
|
expect(textColor(collapsedTitleKey), _headerColor);
|
||||||
expect(iconColor(expandedIconKey), _accentColor);
|
expect(iconColor(expandedIconKey), _foregroundColor);
|
||||||
expect(iconColor(collapsedIconKey), _unselectedWidgetColor);
|
expect(iconColor(collapsedIconKey), _unselectedWidgetColor);
|
||||||
|
|
||||||
// Tap both tiles to change their state: collapse and extend respectively
|
// Tap both tiles to change their state: collapse and extend respectively
|
||||||
@ -208,9 +208,9 @@ void main() {
|
|||||||
await tester.pump(const Duration(seconds: 1));
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
|
||||||
expect(textColor(expandedTitleKey), _headerColor);
|
expect(textColor(expandedTitleKey), _headerColor);
|
||||||
expect(textColor(collapsedTitleKey), _accentColor);
|
expect(textColor(collapsedTitleKey), _foregroundColor);
|
||||||
expect(iconColor(expandedIconKey), _unselectedWidgetColor);
|
expect(iconColor(expandedIconKey), _unselectedWidgetColor);
|
||||||
expect(iconColor(collapsedIconKey), _accentColor);
|
expect(iconColor(collapsedIconKey), _foregroundColor);
|
||||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||||
|
|
||||||
testWidgets('ExpansionTile subtitle', (WidgetTester tester) async {
|
testWidgets('ExpansionTile subtitle', (WidgetTester tester) async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user