Deprecate toggleableActiveColor
(#97972)
This commit is contained in:
parent
c6bb9cc0b8
commit
52829523d6
@ -30,7 +30,6 @@ ThemeData _buildDarkTheme() {
|
||||
primaryColorDark: const Color(0xFF0050a0),
|
||||
primaryColorLight: secondaryColor,
|
||||
indicatorColor: Colors.white,
|
||||
toggleableActiveColor: const Color(0xFF6997DF),
|
||||
canvasColor: const Color(0xFF202124),
|
||||
scaffoldBackgroundColor: const Color(0xFF202124),
|
||||
backgroundColor: const Color(0xFF202124),
|
||||
@ -54,7 +53,6 @@ ThemeData _buildLightTheme() {
|
||||
colorScheme: colorScheme,
|
||||
primaryColor: primaryColor,
|
||||
indicatorColor: Colors.white,
|
||||
toggleableActiveColor: const Color(0xFF1E88E5),
|
||||
splashColor: Colors.white24,
|
||||
splashFactory: InkRipple.splashFactory,
|
||||
canvasColor: Colors.white,
|
||||
|
@ -17,6 +17,438 @@
|
||||
|
||||
version: 1
|
||||
transforms:
|
||||
# Changes made in https://github.com/flutter/flutter/pull/97972/
|
||||
- title: "Migrate 'ThemeData.toggleableActiveColor' to individual themes"
|
||||
date: 2022-05-18
|
||||
element:
|
||||
uris: [ 'material.dart' ]
|
||||
constructor: ''
|
||||
inClass: 'ThemeData'
|
||||
changes:
|
||||
- kind: 'removeParameter'
|
||||
name: 'toggleableActiveColor'
|
||||
- kind: 'addParameter'
|
||||
index: 96
|
||||
name: 'checkboxTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "CheckboxThemeData(\n
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && checkboxTheme == ''"
|
||||
- kind: 'addParameter'
|
||||
index: 97
|
||||
name: 'checkboxTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "{% checkboxTheme %}.copyWith(\n
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && checkboxTheme != ''"
|
||||
- kind: 'addParameter'
|
||||
index: 98
|
||||
name: 'radioTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "RadioThemeData(\n
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && radioTheme == ''"
|
||||
- kind: 'addParameter'
|
||||
index: 99
|
||||
name: 'radioTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "{% radioTheme %}.copyWith(\n
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && radioTheme != ''"
|
||||
- kind: 'addParameter'
|
||||
index: 100
|
||||
name: 'switchTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "SwitchThemeData(\n
|
||||
thumbColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
trackColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && switchTheme == ''"
|
||||
- kind: 'addParameter'
|
||||
index: 101
|
||||
name: 'switchTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "{% switchTheme %}.copyWith(\n
|
||||
thumbColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
trackColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && switchTheme != ''"
|
||||
variables:
|
||||
checkboxTheme:
|
||||
kind: 'fragment'
|
||||
value: 'arguments[checkboxTheme]'
|
||||
radioTheme:
|
||||
kind: 'fragment'
|
||||
value: 'arguments[radioTheme]'
|
||||
switchTheme:
|
||||
kind: 'fragment'
|
||||
value: 'arguments[switchTheme]'
|
||||
toggleableActiveColor:
|
||||
kind: 'fragment'
|
||||
value: 'arguments[toggleableActiveColor]'
|
||||
|
||||
# Changes made in https://github.com/flutter/flutter/pull/97972/
|
||||
- title: "Migrate 'ThemeData.raw.toggleableActiveColor' to individual themes"
|
||||
date: 2022-05-18
|
||||
element:
|
||||
uris: [ 'material.dart' ]
|
||||
constructor: 'raw'
|
||||
inClass: 'ThemeData'
|
||||
changes:
|
||||
- kind: 'removeParameter'
|
||||
name: 'toggleableActiveColor'
|
||||
- kind: 'addParameter'
|
||||
index: 96
|
||||
name: 'checkboxTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "CheckboxThemeData(\n
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && checkboxTheme == ''"
|
||||
- kind: 'addParameter'
|
||||
index: 97
|
||||
name: 'checkboxTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "{% checkboxTheme %}.copyWith(\n
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && checkboxTheme != ''"
|
||||
- kind: 'addParameter'
|
||||
index: 98
|
||||
name: 'radioTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "RadioThemeData(\n
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && radioTheme == ''"
|
||||
- kind: 'addParameter'
|
||||
index: 99
|
||||
name: 'radioTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "{% radioTheme %}.copyWith(\n
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && radioTheme != ''"
|
||||
- kind: 'addParameter'
|
||||
index: 100
|
||||
name: 'switchTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "SwitchThemeData(\n
|
||||
thumbColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
trackColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && switchTheme == ''"
|
||||
- kind: 'addParameter'
|
||||
index: 101
|
||||
name: 'switchTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "{% switchTheme %}.copyWith(\n
|
||||
thumbColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
trackColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && switchTheme != ''"
|
||||
variables:
|
||||
checkboxTheme:
|
||||
kind: 'fragment'
|
||||
value: 'arguments[checkboxTheme]'
|
||||
radioTheme:
|
||||
kind: 'fragment'
|
||||
value: 'arguments[radioTheme]'
|
||||
switchTheme:
|
||||
kind: 'fragment'
|
||||
value: 'arguments[switchTheme]'
|
||||
toggleableActiveColor:
|
||||
kind: 'fragment'
|
||||
value: 'arguments[toggleableActiveColor]'
|
||||
|
||||
# Changes made in https://github.com/flutter/flutter/pull/97972/
|
||||
- title: "Migrate 'ThemeData.copyWith.toggleableActiveColor' to individual themes"
|
||||
date: 2022-05-18
|
||||
element:
|
||||
uris: [ 'material.dart' ]
|
||||
method: 'copyWith'
|
||||
inClass: 'ThemeData'
|
||||
changes:
|
||||
- kind: 'removeParameter'
|
||||
name: 'toggleableActiveColor'
|
||||
- kind: 'addParameter'
|
||||
index: 96
|
||||
name: 'checkboxTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "CheckboxThemeData(\n
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && checkboxTheme == ''"
|
||||
- kind: 'addParameter'
|
||||
index: 97
|
||||
name: 'checkboxTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "{% checkboxTheme %}.copyWith(\n
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && checkboxTheme != ''"
|
||||
- kind: 'addParameter'
|
||||
index: 98
|
||||
name: 'radioTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "RadioThemeData(\n
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && radioTheme == ''"
|
||||
- kind: 'addParameter'
|
||||
index: 99
|
||||
name: 'radioTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "{% radioTheme %}.copyWith(\n
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && radioTheme != ''"
|
||||
- kind: 'addParameter'
|
||||
index: 100
|
||||
name: 'switchTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "SwitchThemeData(\n
|
||||
thumbColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
trackColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && switchTheme == ''"
|
||||
- kind: 'addParameter'
|
||||
index: 101
|
||||
name: 'switchTheme'
|
||||
style: optional_named
|
||||
argumentValue:
|
||||
expression: "{% switchTheme %}.copyWith(\n
|
||||
thumbColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
trackColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {\n
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}\n
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return {% toggleableActiveColor %};
|
||||
}\n
|
||||
return null;\n
|
||||
}),\n
|
||||
)"
|
||||
requiredIf: "toggleableActiveColor != '' && switchTheme != ''"
|
||||
variables:
|
||||
checkboxTheme:
|
||||
kind: 'fragment'
|
||||
value: 'arguments[checkboxTheme]'
|
||||
radioTheme:
|
||||
kind: 'fragment'
|
||||
value: 'arguments[radioTheme]'
|
||||
switchTheme:
|
||||
kind: 'fragment'
|
||||
value: 'arguments[switchTheme]'
|
||||
toggleableActiveColor:
|
||||
kind: 'fragment'
|
||||
value: 'arguments[toggleableActiveColor]'
|
||||
|
||||
# Changes made in https://github.com/flutter/flutter/pull/105291
|
||||
- title: "Migrate 'ElevatedButton.styleFrom(primary)' to 'ElevatedButton.styleFrom(backgroundColor)'"
|
||||
date: 2022-05-27
|
||||
|
@ -147,7 +147,7 @@ class Checkbox extends StatefulWidget {
|
||||
|
||||
/// The color to use when this checkbox is checked.
|
||||
///
|
||||
/// Defaults to [ThemeData.toggleableActiveColor].
|
||||
/// Defaults to [ColorScheme.secondary].
|
||||
///
|
||||
/// If [fillColor] returns a non-null color in the [MaterialState.selected]
|
||||
/// state, it will be used instead of this color.
|
||||
@ -185,7 +185,7 @@ class Checkbox extends StatefulWidget {
|
||||
/// If null, then the value of [activeColor] is used in the selected
|
||||
/// state. If that is also null, the value of [CheckboxThemeData.fillColor]
|
||||
/// is used. If that is also null, then [ThemeData.disabledColor] is used in
|
||||
/// the disabled state, [ThemeData.toggleableActiveColor] is used in the
|
||||
/// the disabled state, [ColorScheme.secondary] is used in the
|
||||
/// selected state, and [ThemeData.unselectedWidgetColor] is used in the
|
||||
/// default state.
|
||||
final MaterialStateProperty<Color?>? fillColor;
|
||||
@ -272,7 +272,7 @@ class Checkbox extends StatefulWidget {
|
||||
/// [kRadialReactionAlpha], [focusColor] and [hoverColor] is used in the
|
||||
/// pressed, focused and hovered state. If that is also null,
|
||||
/// the value of [CheckboxThemeData.overlayColor] is used. If that is
|
||||
/// also null, then the value of [ThemeData.toggleableActiveColor] with alpha
|
||||
/// also null, then the value of [ColorScheme.secondary] with alpha
|
||||
/// [kRadialReactionAlpha], [ThemeData.focusColor] and [ThemeData.hoverColor]
|
||||
/// is used in the pressed, focused and hovered state.
|
||||
final MaterialStateProperty<Color?>? overlayColor;
|
||||
@ -385,7 +385,7 @@ class _CheckboxState extends State<Checkbox> with TickerProviderStateMixin, Togg
|
||||
return themeData.disabledColor;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return themeData.toggleableActiveColor;
|
||||
return themeData.colorScheme.secondary;
|
||||
}
|
||||
return themeData.unselectedWidgetColor;
|
||||
});
|
||||
|
@ -5,8 +5,10 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'checkbox.dart';
|
||||
import 'checkbox_theme.dart';
|
||||
import 'list_tile.dart';
|
||||
import 'list_tile_theme.dart';
|
||||
import 'material_state.dart';
|
||||
import 'theme.dart';
|
||||
import 'theme_data.dart';
|
||||
|
||||
@ -29,7 +31,7 @@ import 'theme_data.dart';
|
||||
///
|
||||
/// The [selected] property on this widget is similar to the [ListTile.selected]
|
||||
/// property. This tile's [activeColor] is used for the selected item's text color, or
|
||||
/// the theme's [ThemeData.toggleableActiveColor] if [activeColor] is null.
|
||||
/// the theme's [CheckboxThemeData.overlayColor] if [activeColor] is null.
|
||||
///
|
||||
/// This widget does not coordinate the [selected] state and the [value] state; to have the list tile
|
||||
/// appear selected when the checkbox is checked, pass the same value to both.
|
||||
@ -372,10 +374,17 @@ class CheckboxListTile extends StatelessWidget {
|
||||
trailing = control;
|
||||
break;
|
||||
}
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final CheckboxThemeData checkboxTheme = CheckboxTheme.of(context);
|
||||
final Set<MaterialState> states = <MaterialState>{
|
||||
if (selected) MaterialState.selected,
|
||||
};
|
||||
final Color effectiveActiveColor = activeColor
|
||||
?? checkboxTheme.fillColor?.resolve(states)
|
||||
?? theme.colorScheme.secondary;
|
||||
return MergeSemantics(
|
||||
child: ListTileTheme.merge(
|
||||
selectedColor: activeColor ?? Theme.of(context).toggleableActiveColor,
|
||||
child: ListTile(
|
||||
selectedColor: effectiveActiveColor,
|
||||
leading: leading,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
@ -394,7 +403,6 @@ class CheckboxListTile extends StatelessWidget {
|
||||
focusNode: focusNode,
|
||||
enableFeedback: enableFeedback,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ class Radio<T> extends StatefulWidget {
|
||||
|
||||
/// The color to use when this radio button is selected.
|
||||
///
|
||||
/// Defaults to [ThemeData.toggleableActiveColor].
|
||||
/// Defaults to [ColorScheme.secondary].
|
||||
///
|
||||
/// If [fillColor] returns a non-null color in the [MaterialState.selected]
|
||||
/// state, it will be used instead of this color.
|
||||
@ -214,7 +214,7 @@ class Radio<T> extends StatefulWidget {
|
||||
/// If null, then the value of [activeColor] is used in the selected state. If
|
||||
/// that is also null, then the value of [RadioThemeData.fillColor] is used.
|
||||
/// If that is also null, then [ThemeData.disabledColor] is used in
|
||||
/// the disabled state, [ThemeData.toggleableActiveColor] is used in the
|
||||
/// the disabled state, [ColorScheme.secondary] is used in the
|
||||
/// selected state, and [ThemeData.unselectedWidgetColor] is used in the
|
||||
/// default state.
|
||||
final MaterialStateProperty<Color?>? fillColor;
|
||||
@ -281,7 +281,7 @@ class Radio<T> extends StatefulWidget {
|
||||
/// [kRadialReactionAlpha], [focusColor] and [hoverColor] is used in the
|
||||
/// pressed, focused and hovered state. If that is also null,
|
||||
/// the value of [RadioThemeData.overlayColor] is used. If that is also null,
|
||||
/// then the value of [ThemeData.toggleableActiveColor] with alpha
|
||||
/// then the value of [ColorScheme.secondary] with alpha
|
||||
/// [kRadialReactionAlpha], [ThemeData.focusColor] and [ThemeData.hoverColor]
|
||||
/// is used in the pressed, focused and hovered state.
|
||||
final MaterialStateProperty<Color?>? overlayColor;
|
||||
@ -361,7 +361,7 @@ class _RadioState<T> extends State<Radio<T>> with TickerProviderStateMixin, Togg
|
||||
return themeData.disabledColor;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return themeData.toggleableActiveColor;
|
||||
return themeData.colorScheme.secondary;
|
||||
}
|
||||
return themeData.unselectedWidgetColor;
|
||||
});
|
||||
|
@ -6,7 +6,9 @@ import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'list_tile.dart';
|
||||
import 'list_tile_theme.dart';
|
||||
import 'material_state.dart';
|
||||
import 'radio.dart';
|
||||
import 'radio_theme.dart';
|
||||
import 'theme.dart';
|
||||
import 'theme_data.dart';
|
||||
|
||||
@ -346,10 +348,17 @@ class RadioListTile<T> extends StatelessWidget {
|
||||
trailing = control;
|
||||
break;
|
||||
}
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final RadioThemeData radioThemeData = RadioTheme.of(context);
|
||||
final Set<MaterialState> states = <MaterialState>{
|
||||
if (selected) MaterialState.selected,
|
||||
};
|
||||
final Color effectiveActiveColor = activeColor
|
||||
?? radioThemeData.fillColor?.resolve(states)
|
||||
?? theme.colorScheme.secondary;
|
||||
return MergeSemantics(
|
||||
child: ListTileTheme.merge(
|
||||
selectedColor: activeColor ?? Theme.of(context).toggleableActiveColor,
|
||||
child: ListTile(
|
||||
selectedColor: effectiveActiveColor,
|
||||
leading: leading,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
@ -376,7 +385,6 @@ class RadioListTile<T> extends StatelessWidget {
|
||||
focusNode: focusNode,
|
||||
enableFeedback: enableFeedback,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ class Switch extends StatelessWidget {
|
||||
|
||||
/// The color to use when this switch is on.
|
||||
///
|
||||
/// Defaults to [ThemeData.toggleableActiveColor].
|
||||
/// Defaults to [ColorScheme.secondary].
|
||||
///
|
||||
/// If [thumbColor] returns a non-null color in the [MaterialState.selected]
|
||||
/// state, it will be used instead of this color.
|
||||
@ -190,7 +190,7 @@ class Switch extends StatelessWidget {
|
||||
|
||||
/// The color to use on the track when this switch is on.
|
||||
///
|
||||
/// Defaults to [ThemeData.toggleableActiveColor] with the opacity set at 50%.
|
||||
/// Defaults to [ColorScheme.secondary] with the opacity set at 50%.
|
||||
///
|
||||
/// Ignored if this switch is created with [Switch.adaptive].
|
||||
///
|
||||
@ -273,7 +273,7 @@ class Switch extends StatelessWidget {
|
||||
/// | State | Light theme | Dark theme |
|
||||
/// |----------|-----------------------------------|-----------------------------------|
|
||||
/// | Default | `Colors.grey.shade50` | `Colors.grey.shade400` |
|
||||
/// | Selected | [ThemeData.toggleableActiveColor] | [ThemeData.toggleableActiveColor] |
|
||||
/// | Selected | [ColorScheme.secondary] | [ColorScheme.secondary] |
|
||||
/// | Disabled | `Colors.grey.shade400` | `Colors.grey.shade800` |
|
||||
final MaterialStateProperty<Color?>? thumbColor;
|
||||
|
||||
@ -393,7 +393,7 @@ class Switch extends StatelessWidget {
|
||||
/// [kRadialReactionAlpha], [focusColor] and [hoverColor] is used in the
|
||||
/// pressed, focused and hovered state. If that is also null,
|
||||
/// the value of [SwitchThemeData.overlayColor] is used. If that is
|
||||
/// also null, then the value of [ThemeData.toggleableActiveColor] with alpha
|
||||
/// also null, then the value of [ColorScheme.secondary] with alpha
|
||||
/// [kRadialReactionAlpha], [ThemeData.focusColor] and [ThemeData.hoverColor]
|
||||
/// is used in the pressed, focused and hovered state.
|
||||
final MaterialStateProperty<Color?>? overlayColor;
|
||||
@ -614,7 +614,7 @@ class _MaterialSwitchState extends State<_MaterialSwitch> with TickerProviderSta
|
||||
return isDark ? Colors.grey.shade800 : Colors.grey.shade400;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return theme.toggleableActiveColor;
|
||||
return theme.colorScheme.secondary;
|
||||
}
|
||||
return isDark ? Colors.grey.shade400 : Colors.grey.shade50;
|
||||
});
|
||||
|
@ -6,7 +6,9 @@ import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'list_tile.dart';
|
||||
import 'list_tile_theme.dart';
|
||||
import 'material_state.dart';
|
||||
import 'switch.dart';
|
||||
import 'switch_theme.dart';
|
||||
import 'theme.dart';
|
||||
import 'theme_data.dart';
|
||||
|
||||
@ -37,7 +39,7 @@ enum _SwitchListTileType { material, adaptive }
|
||||
///
|
||||
/// The [selected] property on this widget is similar to the [ListTile.selected]
|
||||
/// property. This tile's [activeColor] is used for the selected item's text color, or
|
||||
/// the theme's [ThemeData.toggleableActiveColor] if [activeColor] is null.
|
||||
/// the theme's [SwitchThemeData.overlayColor] if [activeColor] is null.
|
||||
///
|
||||
/// This widget does not coordinate the [selected] state and the
|
||||
/// [value]; to have the list tile appear selected when the
|
||||
@ -423,10 +425,17 @@ class SwitchListTile extends StatelessWidget {
|
||||
break;
|
||||
}
|
||||
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final SwitchThemeData switchTheme = SwitchTheme.of(context);
|
||||
final Set<MaterialState> states = <MaterialState>{
|
||||
if (selected) MaterialState.selected,
|
||||
};
|
||||
final Color effectiveActiveColor = activeColor
|
||||
?? switchTheme.thumbColor?.resolve(states)
|
||||
?? theme.colorScheme.secondary;
|
||||
return MergeSemantics(
|
||||
child: ListTileTheme.merge(
|
||||
selectedColor: activeColor ?? Theme.of(context).toggleableActiveColor,
|
||||
child: ListTile(
|
||||
selectedColor: effectiveActiveColor,
|
||||
leading: leading,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
@ -446,7 +455,6 @@ class SwitchListTile extends StatelessWidget {
|
||||
enableFeedback: enableFeedback,
|
||||
hoverColor: hoverColor,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -313,7 +313,6 @@ class ThemeData with Diagnosticable {
|
||||
Color? selectedRowColor,
|
||||
Color? shadowColor,
|
||||
Color? splashColor,
|
||||
Color? toggleableActiveColor,
|
||||
Color? unselectedWidgetColor,
|
||||
// TYPOGRAPHY & ICONOGRAPHY
|
||||
String? fontFamily,
|
||||
@ -405,6 +404,13 @@ class ThemeData with Diagnosticable {
|
||||
'This feature was deprecated after v2.13.0-0.0.pre.'
|
||||
)
|
||||
AndroidOverscrollIndicator? androidOverscrollIndicator,
|
||||
@Deprecated(
|
||||
'No longer used by the framework, please remove any reference to it. '
|
||||
'For more information, consult the migration guide at '
|
||||
'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. '
|
||||
'This feature was deprecated after v2.13.0-0.4.pre.',
|
||||
)
|
||||
Color? toggleableActiveColor,
|
||||
}) {
|
||||
// GENERAL CONFIGURATION
|
||||
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
|
||||
@ -614,7 +620,6 @@ class ThemeData with Diagnosticable {
|
||||
selectedRowColor: selectedRowColor,
|
||||
shadowColor: shadowColor,
|
||||
splashColor: splashColor,
|
||||
toggleableActiveColor: toggleableActiveColor,
|
||||
unselectedWidgetColor: unselectedWidgetColor,
|
||||
// TYPOGRAPHY & ICONOGRAPHY
|
||||
iconTheme: iconTheme,
|
||||
@ -665,6 +670,7 @@ class ThemeData with Diagnosticable {
|
||||
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel,
|
||||
primaryColorBrightness: primaryColorBrightness,
|
||||
androidOverscrollIndicator: androidOverscrollIndicator,
|
||||
toggleableActiveColor: toggleableActiveColor,
|
||||
);
|
||||
}
|
||||
|
||||
@ -719,7 +725,6 @@ class ThemeData with Diagnosticable {
|
||||
required this.selectedRowColor,
|
||||
required this.shadowColor,
|
||||
required this.splashColor,
|
||||
required this.toggleableActiveColor,
|
||||
required this.unselectedWidgetColor,
|
||||
// TYPOGRAPHY & ICONOGRAPHY
|
||||
required this.iconTheme,
|
||||
@ -810,6 +815,13 @@ class ThemeData with Diagnosticable {
|
||||
'This feature was deprecated after v2.13.0-0.0.pre.'
|
||||
)
|
||||
this.androidOverscrollIndicator,
|
||||
@Deprecated(
|
||||
'No longer used by the framework, please remove any reference to it. '
|
||||
'For more information, consult the migration guide at '
|
||||
'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. '
|
||||
'This feature was deprecated after v2.13.0-0.4.pre.',
|
||||
)
|
||||
Color? toggleableActiveColor,
|
||||
}) : // DEPRECATED (newest deprecations at the bottom)
|
||||
// should not be `required`, use getter pattern to avoid breakages.
|
||||
_accentColor = accentColor,
|
||||
@ -819,6 +831,7 @@ class ThemeData with Diagnosticable {
|
||||
_buttonColor = buttonColor,
|
||||
_fixTextFieldOutlineLabel = fixTextFieldOutlineLabel,
|
||||
_primaryColorBrightness = primaryColorBrightness,
|
||||
_toggleableActiveColor = toggleableActiveColor,
|
||||
// GENERAL CONFIGURATION
|
||||
assert(applyElevationOverlayColor != null),
|
||||
assert(extensions != null),
|
||||
@ -1341,7 +1354,8 @@ class ThemeData with Diagnosticable {
|
||||
|
||||
/// The color used to highlight the active states of toggleable widgets like
|
||||
/// [Switch], [Radio], and [Checkbox].
|
||||
final Color toggleableActiveColor;
|
||||
Color get toggleableActiveColor => _toggleableActiveColor!;
|
||||
final Color? _toggleableActiveColor;
|
||||
|
||||
/// The color used for widgets in their inactive (but enabled)
|
||||
/// state. For example, an unchecked checkbox. See also [disabledColor].
|
||||
@ -1673,7 +1687,6 @@ class ThemeData with Diagnosticable {
|
||||
Color? selectedRowColor,
|
||||
Color? shadowColor,
|
||||
Color? splashColor,
|
||||
Color? toggleableActiveColor,
|
||||
Color? unselectedWidgetColor,
|
||||
// TYPOGRAPHY & ICONOGRAPHY
|
||||
IconThemeData? iconTheme,
|
||||
@ -1764,6 +1777,13 @@ class ThemeData with Diagnosticable {
|
||||
'This feature was deprecated after v2.13.0-0.0.pre.'
|
||||
)
|
||||
AndroidOverscrollIndicator? androidOverscrollIndicator,
|
||||
@Deprecated(
|
||||
'No longer used by the framework, please remove any reference to it. '
|
||||
'For more information, consult the migration guide at '
|
||||
'https://flutter.dev/docs/release/breaking-changes/toggleable-active-color#migration-guide. '
|
||||
'This feature was deprecated after v2.13.0-0.4.pre.',
|
||||
)
|
||||
Color? toggleableActiveColor,
|
||||
}) {
|
||||
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
|
||||
return ThemeData.raw(
|
||||
@ -1807,7 +1827,6 @@ class ThemeData with Diagnosticable {
|
||||
selectedRowColor: selectedRowColor ?? this.selectedRowColor,
|
||||
shadowColor: shadowColor ?? this.shadowColor,
|
||||
splashColor: splashColor ?? this.splashColor,
|
||||
toggleableActiveColor: toggleableActiveColor ?? this.toggleableActiveColor,
|
||||
unselectedWidgetColor: unselectedWidgetColor ?? this.unselectedWidgetColor,
|
||||
// TYPOGRAPHY & ICONOGRAPHY
|
||||
iconTheme: iconTheme ?? this.iconTheme,
|
||||
@ -1858,6 +1877,7 @@ class ThemeData with Diagnosticable {
|
||||
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel ?? this.fixTextFieldOutlineLabel,
|
||||
primaryColorBrightness: primaryColorBrightness ?? this.primaryColorBrightness,
|
||||
androidOverscrollIndicator: androidOverscrollIndicator ?? this.androidOverscrollIndicator,
|
||||
toggleableActiveColor: toggleableActiveColor ?? this.toggleableActiveColor,
|
||||
);
|
||||
}
|
||||
|
||||
@ -2005,7 +2025,6 @@ class ThemeData with Diagnosticable {
|
||||
selectedRowColor: Color.lerp(a.selectedRowColor, b.selectedRowColor, t)!,
|
||||
shadowColor: Color.lerp(a.shadowColor, b.shadowColor, t)!,
|
||||
splashColor: Color.lerp(a.splashColor, b.splashColor, t)!,
|
||||
toggleableActiveColor: Color.lerp(a.toggleableActiveColor, b.toggleableActiveColor, t)!,
|
||||
unselectedWidgetColor: Color.lerp(a.unselectedWidgetColor, b.unselectedWidgetColor, t)!,
|
||||
// TYPOGRAPHY & ICONOGRAPHY
|
||||
iconTheme: IconThemeData.lerp(a.iconTheme, b.iconTheme, t),
|
||||
@ -2056,6 +2075,7 @@ class ThemeData with Diagnosticable {
|
||||
fixTextFieldOutlineLabel: t < 0.5 ? a.fixTextFieldOutlineLabel : b.fixTextFieldOutlineLabel,
|
||||
primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness,
|
||||
androidOverscrollIndicator:t < 0.5 ? a.androidOverscrollIndicator : b.androidOverscrollIndicator,
|
||||
toggleableActiveColor: Color.lerp(a.toggleableActiveColor, b.toggleableActiveColor, t),
|
||||
);
|
||||
}
|
||||
|
||||
@ -2105,7 +2125,6 @@ class ThemeData with Diagnosticable {
|
||||
other.selectedRowColor == selectedRowColor &&
|
||||
other.shadowColor == shadowColor &&
|
||||
other.splashColor == splashColor &&
|
||||
other.toggleableActiveColor == toggleableActiveColor &&
|
||||
other.unselectedWidgetColor == unselectedWidgetColor &&
|
||||
// TYPOGRAPHY & ICONOGRAPHY
|
||||
other.iconTheme == iconTheme &&
|
||||
@ -2155,7 +2174,8 @@ class ThemeData with Diagnosticable {
|
||||
other.buttonColor == buttonColor &&
|
||||
other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel &&
|
||||
other.primaryColorBrightness == primaryColorBrightness &&
|
||||
other.androidOverscrollIndicator == androidOverscrollIndicator;
|
||||
other.androidOverscrollIndicator == androidOverscrollIndicator &&
|
||||
other.toggleableActiveColor == toggleableActiveColor;
|
||||
}
|
||||
|
||||
@override
|
||||
@ -2202,7 +2222,6 @@ class ThemeData with Diagnosticable {
|
||||
selectedRowColor,
|
||||
shadowColor,
|
||||
splashColor,
|
||||
toggleableActiveColor,
|
||||
unselectedWidgetColor,
|
||||
// TYPOGRAPHY & ICONOGRAPHY
|
||||
iconTheme,
|
||||
@ -2253,6 +2272,7 @@ class ThemeData with Diagnosticable {
|
||||
fixTextFieldOutlineLabel,
|
||||
primaryColorBrightness,
|
||||
androidOverscrollIndicator,
|
||||
toggleableActiveColor,
|
||||
];
|
||||
return Object.hashAll(values);
|
||||
}
|
||||
@ -2301,7 +2321,6 @@ class ThemeData with Diagnosticable {
|
||||
properties.add(ColorProperty('selectedRowColor', selectedRowColor, defaultValue: defaultData.selectedRowColor, level: DiagnosticLevel.debug));
|
||||
properties.add(ColorProperty('shadowColor', shadowColor, defaultValue: defaultData.shadowColor, level: DiagnosticLevel.debug));
|
||||
properties.add(ColorProperty('splashColor', splashColor, defaultValue: defaultData.splashColor, level: DiagnosticLevel.debug));
|
||||
properties.add(ColorProperty('toggleableActiveColor', toggleableActiveColor, defaultValue: defaultData.toggleableActiveColor, level: DiagnosticLevel.debug));
|
||||
properties.add(ColorProperty('unselectedWidgetColor', unselectedWidgetColor, defaultValue: defaultData.unselectedWidgetColor, level: DiagnosticLevel.debug));
|
||||
// TYPOGRAPHY & ICONOGRAPHY
|
||||
properties.add(DiagnosticsProperty<IconThemeData>('iconTheme', iconTheme, level: DiagnosticLevel.debug));
|
||||
@ -2352,6 +2371,7 @@ class ThemeData with Diagnosticable {
|
||||
properties.add(DiagnosticsProperty<bool>('fixTextFieldOutlineLabel', fixTextFieldOutlineLabel, level: DiagnosticLevel.debug));
|
||||
properties.add(EnumProperty<Brightness>('primaryColorBrightness', primaryColorBrightness, defaultValue: defaultData.primaryColorBrightness, level: DiagnosticLevel.debug));
|
||||
properties.add(EnumProperty<AndroidOverscrollIndicator>('androidOverscrollIndicator', androidOverscrollIndicator, defaultValue: null, level: DiagnosticLevel.debug));
|
||||
properties.add(ColorProperty('toggleableActiveColor', toggleableActiveColor, defaultValue: defaultData.toggleableActiveColor, level: DiagnosticLevel.debug));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('CheckboxListTile checkColor test', (WidgetTester tester) async {
|
||||
const Color checkBoxBorderColor = Color(0xff1e88e5);
|
||||
const Color checkBoxBorderColor = Color(0xff2196f3);
|
||||
Color checkBoxCheckColor = const Color(0xffFFFFFF);
|
||||
|
||||
Widget buildFrame(Color? color) {
|
||||
@ -68,7 +68,13 @@ void main() {
|
||||
Widget buildFrame(Color? themeColor, Color? activeColor) {
|
||||
return wrap(
|
||||
child: Theme(
|
||||
data: ThemeData(toggleableActiveColor: themeColor),
|
||||
data: ThemeData(
|
||||
checkboxTheme: CheckboxThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
return states.contains(MaterialState.selected) ? themeColor : null;
|
||||
}),
|
||||
),
|
||||
),
|
||||
child: CheckboxListTile(
|
||||
value: true,
|
||||
activeColor: activeColor,
|
||||
@ -291,10 +297,14 @@ void main() {
|
||||
|
||||
const Color activeColor = Color(0xff00ff00);
|
||||
|
||||
Widget buildFrame({ Color? activeColor, Color? toggleableActiveColor }) {
|
||||
Widget buildFrame({ Color? activeColor, Color? fillColor }) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData.light().copyWith(
|
||||
toggleableActiveColor: toggleableActiveColor,
|
||||
checkboxTheme: CheckboxThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
return states.contains(MaterialState.selected) ? fillColor : null;
|
||||
}),
|
||||
),
|
||||
),
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
@ -314,7 +324,7 @@ void main() {
|
||||
return tester.renderObject<RenderParagraph>(find.text(text)).text.style?.color;
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildFrame(toggleableActiveColor: activeColor));
|
||||
await tester.pumpWidget(buildFrame(fillColor: activeColor));
|
||||
expect(textColor('title'), activeColor);
|
||||
|
||||
await tester.pumpWidget(buildFrame(activeColor: activeColor));
|
||||
|
@ -353,7 +353,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('CheckBox color rendering', (WidgetTester tester) async {
|
||||
const Color borderColor = Color(0xff1e88e5);
|
||||
const Color borderColor = Color(0xff2196f3);
|
||||
Color checkColor = const Color(0xffFFFFFF);
|
||||
Color activeColor;
|
||||
|
||||
@ -391,7 +391,11 @@ void main() {
|
||||
|
||||
activeColor = const Color(0xFF00FF00);
|
||||
|
||||
await tester.pumpWidget(buildFrame(themeData: ThemeData(toggleableActiveColor: activeColor)));
|
||||
await tester.pumpWidget(buildFrame(
|
||||
themeData: ThemeData(
|
||||
colorScheme: const ColorScheme.light()
|
||||
.copyWith(secondary: activeColor))),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(getCheckboxRenderer(), paints..path(color: activeColor)); // paints's color is 0xFF00FF00 (theme)
|
||||
|
||||
@ -435,7 +439,7 @@ void main() {
|
||||
Material.of(tester.element(find.byType(Checkbox))),
|
||||
paints
|
||||
..circle(color: Colors.orange[500])
|
||||
..path(color: const Color(0xff1e88e5))
|
||||
..path(color: const Color(0xff2196f3))
|
||||
..path(color: Colors.white),
|
||||
);
|
||||
|
||||
@ -526,7 +530,7 @@ void main() {
|
||||
expect(
|
||||
Material.of(tester.element(find.byType(Checkbox))),
|
||||
paints
|
||||
..path(color: const Color(0xff1e88e5))
|
||||
..path(color: const Color(0xff2196f3))
|
||||
..path(color: const Color(0xffffffff),style: PaintingStyle.stroke, strokeWidth: 2.0),
|
||||
);
|
||||
|
||||
@ -539,7 +543,7 @@ void main() {
|
||||
expect(
|
||||
Material.of(tester.element(find.byType(Checkbox))),
|
||||
paints
|
||||
..path(color: const Color(0xff1e88e5))
|
||||
..path(color: const Color(0xff2196f3))
|
||||
..path(color: const Color(0xffffffff), style: PaintingStyle.stroke, strokeWidth: 2.0),
|
||||
);
|
||||
|
||||
|
@ -710,10 +710,14 @@ void main() {
|
||||
|
||||
const Color activeColor = Color(0xff00ff00);
|
||||
|
||||
Widget buildFrame({ Color? activeColor, Color? toggleableActiveColor }) {
|
||||
Widget buildFrame({ Color? activeColor, Color? fillColor }) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData.light().copyWith(
|
||||
toggleableActiveColor: toggleableActiveColor,
|
||||
radioTheme: RadioThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
return states.contains(MaterialState.selected) ? fillColor : null;
|
||||
}),
|
||||
),
|
||||
),
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
@ -734,7 +738,7 @@ void main() {
|
||||
return tester.renderObject<RenderParagraph>(find.text(text)).text.style?.color;
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildFrame(toggleableActiveColor: activeColor));
|
||||
await tester.pumpWidget(buildFrame(fillColor: activeColor));
|
||||
expect(textColor('title'), activeColor);
|
||||
|
||||
await tester.pumpWidget(buildFrame(activeColor: activeColor));
|
||||
|
@ -441,8 +441,8 @@ void main() {
|
||||
rect: const Rect.fromLTRB(350.0, 250.0, 450.0, 350.0),
|
||||
)
|
||||
..circle(color: Colors.orange[500])
|
||||
..circle(color: const Color(0xff1e88e5))
|
||||
..circle(color: const Color(0xff1e88e5)),
|
||||
..circle(color: const Color(0xff2196f3))
|
||||
..circle(color: const Color(0xff2196f3)),
|
||||
);
|
||||
|
||||
// Check when the radio isn't selected.
|
||||
@ -519,8 +519,8 @@ void main() {
|
||||
color: const Color(0xffffffff),
|
||||
rect: const Rect.fromLTRB(350.0, 250.0, 450.0, 350.0),
|
||||
)
|
||||
..circle(color: const Color(0xff1e88e5))
|
||||
..circle(color: const Color(0xff1e88e5)),
|
||||
..circle(color: const Color(0xff2196f3))
|
||||
..circle(color: const Color(0xff2196f3)),
|
||||
);
|
||||
|
||||
// Start hovering
|
||||
|
@ -400,10 +400,14 @@ void main() {
|
||||
|
||||
const Color activeColor = Color(0xff00ff00);
|
||||
|
||||
Widget buildFrame({ Color? activeColor, Color? toggleableActiveColor }) {
|
||||
Widget buildFrame({ Color? activeColor, Color? thumbColor }) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData.light().copyWith(
|
||||
toggleableActiveColor: toggleableActiveColor,
|
||||
switchTheme: SwitchThemeData(
|
||||
thumbColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
return states.contains(MaterialState.selected) ? thumbColor : null;
|
||||
}),
|
||||
),
|
||||
),
|
||||
home: Scaffold(
|
||||
body: Center(
|
||||
@ -423,7 +427,7 @@ void main() {
|
||||
return tester.renderObject<RenderParagraph>(find.text(text)).text.style?.color;
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildFrame(toggleableActiveColor: activeColor));
|
||||
await tester.pumpWidget(buildFrame(activeColor: activeColor));
|
||||
expect(textColor('title'), activeColor);
|
||||
|
||||
await tester.pumpWidget(buildFrame(activeColor: activeColor));
|
||||
|
@ -373,13 +373,13 @@ void main() {
|
||||
Material.of(tester.element(find.byType(Switch))),
|
||||
paints
|
||||
..rrect(
|
||||
color: Colors.blue[600]!.withAlpha(0x80),
|
||||
color: const Color(0x802196f3),
|
||||
rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)),
|
||||
)
|
||||
..circle(color: const Color(0x33000000))
|
||||
..circle(color: const Color(0x24000000))
|
||||
..circle(color: const Color(0x1f000000))
|
||||
..circle(color: Colors.blue[600]),
|
||||
..circle(color: const Color(0xff2196f3)),
|
||||
reason: 'Active enabled switch should match these colors',
|
||||
);
|
||||
});
|
||||
@ -806,14 +806,14 @@ void main() {
|
||||
Material.of(tester.element(find.byType(Switch))),
|
||||
paints
|
||||
..rrect(
|
||||
color: const Color(0x801e88e5),
|
||||
color: const Color(0x802196f3),
|
||||
rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)),
|
||||
)
|
||||
..circle(color: Colors.orange[500])
|
||||
..circle(color: const Color(0x33000000))
|
||||
..circle(color: const Color(0x24000000))
|
||||
..circle(color: const Color(0x1f000000))
|
||||
..circle(color: const Color(0xff1e88e5)),
|
||||
..circle(color: const Color(0xff2196f3)),
|
||||
);
|
||||
|
||||
// Check the false value.
|
||||
@ -910,13 +910,13 @@ void main() {
|
||||
Material.of(tester.element(find.byType(Switch))),
|
||||
paints
|
||||
..rrect(
|
||||
color: const Color(0x801e88e5),
|
||||
color: const Color(0x802196f3),
|
||||
rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)),
|
||||
)
|
||||
..circle(color: const Color(0x33000000))
|
||||
..circle(color: const Color(0x24000000))
|
||||
..circle(color: const Color(0x1f000000))
|
||||
..circle(color: const Color(0xff1e88e5)),
|
||||
..circle(color: const Color(0xff2196f3)),
|
||||
);
|
||||
|
||||
// Start hovering
|
||||
@ -930,14 +930,14 @@ void main() {
|
||||
Material.of(tester.element(find.byType(Switch))),
|
||||
paints
|
||||
..rrect(
|
||||
color: const Color(0x801e88e5),
|
||||
color: const Color(0x802196f3),
|
||||
rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)),
|
||||
)
|
||||
..circle(color: Colors.orange[500])
|
||||
..circle(color: const Color(0x33000000))
|
||||
..circle(color: const Color(0x24000000))
|
||||
..circle(color: const Color(0x1f000000))
|
||||
..circle(color: const Color(0xff1e88e5)),
|
||||
..circle(color: const Color(0xff2196f3)),
|
||||
);
|
||||
|
||||
// Check what happens when disabled.
|
||||
@ -1297,7 +1297,7 @@ void main() {
|
||||
Material.of(tester.element(find.byType(Switch))),
|
||||
paints
|
||||
..rrect(
|
||||
color: const Color(0x801e88e5),
|
||||
color: const Color(0x802196f3),
|
||||
rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)),
|
||||
)
|
||||
..circle(color: const Color(0x1f000000))
|
||||
@ -1318,7 +1318,7 @@ void main() {
|
||||
Material.of(tester.element(find.byType(Switch))),
|
||||
paints
|
||||
..rrect(
|
||||
color: const Color(0x801e88e5),
|
||||
color: const Color(0x802196f3),
|
||||
rrect: RRect.fromLTRBR(13.0, 17.0, 46.0, 31.0, const Radius.circular(7.0)),
|
||||
)
|
||||
..circle(color: const Color(0x1f000000))
|
||||
|
@ -672,7 +672,6 @@ void main() {
|
||||
selectedRowColor: Colors.black,
|
||||
shadowColor: Colors.black,
|
||||
splashColor: Colors.black,
|
||||
toggleableActiveColor: Colors.black,
|
||||
unselectedWidgetColor: Colors.black,
|
||||
// TYPOGRAPHY & ICONOGRAPHY
|
||||
iconTheme: ThemeData.dark().iconTheme,
|
||||
@ -723,6 +722,7 @@ void main() {
|
||||
fixTextFieldOutlineLabel: false,
|
||||
primaryColorBrightness: Brightness.dark,
|
||||
androidOverscrollIndicator: AndroidOverscrollIndicator.glow,
|
||||
toggleableActiveColor: Colors.black,
|
||||
);
|
||||
|
||||
final SliderThemeData otherSliderTheme = SliderThemeData.fromPrimaryColors(
|
||||
@ -782,7 +782,6 @@ void main() {
|
||||
selectedRowColor: Colors.white,
|
||||
shadowColor: Colors.white,
|
||||
splashColor: Colors.white,
|
||||
toggleableActiveColor: Colors.white,
|
||||
unselectedWidgetColor: Colors.white,
|
||||
|
||||
// TYPOGRAPHY & ICONOGRAPHY
|
||||
@ -836,6 +835,7 @@ void main() {
|
||||
fixTextFieldOutlineLabel: true,
|
||||
primaryColorBrightness: Brightness.light,
|
||||
androidOverscrollIndicator: AndroidOverscrollIndicator.stretch,
|
||||
toggleableActiveColor: Colors.white,
|
||||
);
|
||||
|
||||
final ThemeData themeDataCopy = theme.copyWith(
|
||||
@ -880,7 +880,6 @@ void main() {
|
||||
selectedRowColor: otherTheme.selectedRowColor,
|
||||
shadowColor: otherTheme.shadowColor,
|
||||
splashColor: otherTheme.splashColor,
|
||||
toggleableActiveColor: otherTheme.toggleableActiveColor,
|
||||
unselectedWidgetColor: otherTheme.unselectedWidgetColor,
|
||||
|
||||
// TYPOGRAPHY & ICONOGRAPHY
|
||||
@ -934,6 +933,7 @@ void main() {
|
||||
fixTextFieldOutlineLabel: otherTheme.fixTextFieldOutlineLabel,
|
||||
primaryColorBrightness: otherTheme.primaryColorBrightness,
|
||||
androidOverscrollIndicator: otherTheme.androidOverscrollIndicator,
|
||||
toggleableActiveColor: otherTheme.toggleableActiveColor,
|
||||
);
|
||||
|
||||
// For the sanity of the reader, make sure these properties are in the same
|
||||
@ -977,7 +977,6 @@ void main() {
|
||||
expect(themeDataCopy.selectedRowColor, equals(otherTheme.selectedRowColor));
|
||||
expect(themeDataCopy.shadowColor, equals(otherTheme.shadowColor));
|
||||
expect(themeDataCopy.splashColor, equals(otherTheme.splashColor));
|
||||
expect(themeDataCopy.toggleableActiveColor, equals(otherTheme.toggleableActiveColor));
|
||||
expect(themeDataCopy.unselectedWidgetColor, equals(otherTheme.unselectedWidgetColor));
|
||||
|
||||
// TYPOGRAPHY & ICONOGRAPHY
|
||||
@ -1036,6 +1035,7 @@ void main() {
|
||||
expect(themeDataCopy.fixTextFieldOutlineLabel, equals(otherTheme.fixTextFieldOutlineLabel));
|
||||
expect(themeDataCopy.primaryColorBrightness, equals(otherTheme.primaryColorBrightness));
|
||||
expect(themeDataCopy.androidOverscrollIndicator, equals(otherTheme.androidOverscrollIndicator));
|
||||
expect(themeDataCopy.toggleableActiveColor, equals(otherTheme.toggleableActiveColor));
|
||||
});
|
||||
|
||||
testWidgets('ThemeData.toString has less than 200 characters output', (WidgetTester tester) async {
|
||||
@ -1115,7 +1115,6 @@ void main() {
|
||||
'indicatorColor',
|
||||
'hintColor',
|
||||
'errorColor',
|
||||
'toggleableActiveColor',
|
||||
// TYPOGRAPHY & ICONOGRAPHY
|
||||
'typography',
|
||||
'textTheme',
|
||||
@ -1165,6 +1164,7 @@ void main() {
|
||||
'fixTextFieldOutlineLabel',
|
||||
'primaryColorBrightness',
|
||||
'androidOverscrollIndicator',
|
||||
'toggleableActiveColor',
|
||||
};
|
||||
|
||||
final DiagnosticPropertiesBuilder properties = DiagnosticPropertiesBuilder();
|
||||
|
@ -569,4 +569,20 @@ void main() {
|
||||
primary: Colors.blue,
|
||||
onSurface: Colors.grey,
|
||||
);
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/97972
|
||||
ThemeData themeData = ThemeData();
|
||||
themeData = ThemeData(toggleableActiveColor: Colors.black);
|
||||
themeData = ThemeData(
|
||||
toggleableActiveColor: Colors.black,
|
||||
);
|
||||
themeData = ThemeData.raw(toggleableActiveColor: Colors.black);
|
||||
themeData = ThemeData.raw(
|
||||
toggleableActiveColor: Colors.black,
|
||||
);
|
||||
themeData = themeData.copyWith(toggleableActiveColor: Colors.black);
|
||||
themeData = themeData.copyWith(
|
||||
toggleableActiveColor: Colors.black,
|
||||
);
|
||||
themeData.toggleableActiveColor; // Removing field reference not supported.
|
||||
}
|
||||
|
@ -538,4 +538,254 @@ void main() {
|
||||
ButtonStyle textButtonStyle = TextButton.styleFrom(
|
||||
foregroundColor: Colors.blue, disabledForegroundColor: Colors.grey.withOpacity(0.38),
|
||||
);
|
||||
|
||||
// Changes made in https://github.com/flutter/flutter/pull/97972
|
||||
ThemeData themeData = ThemeData();
|
||||
themeData = ThemeData(checkboxTheme: CheckboxThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
), radioTheme: RadioThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
), switchTheme: SwitchThemeData(
|
||||
thumbColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
trackColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
));
|
||||
themeData = ThemeData(
|
||||
checkboxTheme: CheckboxThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
), radioTheme: RadioThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
), switchTheme: SwitchThemeData(
|
||||
thumbColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
trackColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
),
|
||||
);
|
||||
themeData = ThemeData.raw(checkboxTheme: CheckboxThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
), radioTheme: RadioThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
), switchTheme: SwitchThemeData(
|
||||
thumbColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
trackColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
));
|
||||
themeData = ThemeData.raw(
|
||||
checkboxTheme: CheckboxThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
), radioTheme: RadioThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
), switchTheme: SwitchThemeData(
|
||||
thumbColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
trackColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
),
|
||||
);
|
||||
themeData = themeData.copyWith(checkboxTheme: CheckboxThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
), radioTheme: RadioThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
), switchTheme: SwitchThemeData(
|
||||
thumbColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
trackColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
));
|
||||
themeData = themeData.copyWith(
|
||||
checkboxTheme: CheckboxThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
), radioTheme: RadioThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
), switchTheme: SwitchThemeData(
|
||||
thumbColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
trackColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return null;
|
||||
}
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return Colors.black;
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
),
|
||||
);
|
||||
themeData.toggleableActiveColor; // Removing field reference not supported.
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user