Unverified Commit 7d098177 authored by Darren Austin's avatar Darren Austin Committed by GitHub

Added useMaterial3 flag to ThemeData. (#93434)

parent 99e85b1c
...@@ -231,6 +231,7 @@ class ThemeData with Diagnosticable { ...@@ -231,6 +231,7 @@ class ThemeData with Diagnosticable {
ScrollbarThemeData? scrollbarTheme, ScrollbarThemeData? scrollbarTheme,
InteractiveInkFeatureFactory? splashFactory, InteractiveInkFeatureFactory? splashFactory,
VisualDensity? visualDensity, VisualDensity? visualDensity,
bool? useMaterial3,
// COLOR // COLOR
// [colorScheme] is the preferred way to configure colors. The other color // [colorScheme] is the preferred way to configure colors. The other color
// properties (as well as brightness, primaryColorBrightness, and primarySwatch) // properties (as well as brightness, primaryColorBrightness, and primarySwatch)
...@@ -387,6 +388,7 @@ class ThemeData with Diagnosticable { ...@@ -387,6 +388,7 @@ class ThemeData with Diagnosticable {
scrollbarTheme ??= const ScrollbarThemeData(); scrollbarTheme ??= const ScrollbarThemeData();
splashFactory ??= InkSplash.splashFactory; splashFactory ??= InkSplash.splashFactory;
visualDensity ??= VisualDensity.adaptivePlatformDensity; visualDensity ??= VisualDensity.adaptivePlatformDensity;
useMaterial3 ??= false;
// COLOR // COLOR
assert(colorScheme?.brightness == null || brightness == null || colorScheme!.brightness == brightness); assert(colorScheme?.brightness == null || brightness == null || colorScheme!.brightness == brightness);
...@@ -518,6 +520,7 @@ class ThemeData with Diagnosticable { ...@@ -518,6 +520,7 @@ class ThemeData with Diagnosticable {
scrollbarTheme: scrollbarTheme, scrollbarTheme: scrollbarTheme,
splashFactory: splashFactory, splashFactory: splashFactory,
visualDensity: visualDensity, visualDensity: visualDensity,
useMaterial3: useMaterial3,
// COLOR // COLOR
colorScheme: colorScheme, colorScheme: colorScheme,
primaryColor: primaryColor, primaryColor: primaryColor,
...@@ -619,6 +622,7 @@ class ThemeData with Diagnosticable { ...@@ -619,6 +622,7 @@ class ThemeData with Diagnosticable {
required this.scrollbarTheme, required this.scrollbarTheme,
required this.splashFactory, required this.splashFactory,
required this.visualDensity, required this.visualDensity,
required this.useMaterial3,
// COLOR // COLOR
// [colorScheme] is the preferred way to configure colors. The other color // [colorScheme] is the preferred way to configure colors. The other color
// properties will gradually be phased out, see // properties will gradually be phased out, see
...@@ -759,6 +763,7 @@ class ThemeData with Diagnosticable { ...@@ -759,6 +763,7 @@ class ThemeData with Diagnosticable {
assert(scrollbarTheme != null), assert(scrollbarTheme != null),
assert(splashFactory != null), assert(splashFactory != null),
assert(visualDensity != null), assert(visualDensity != null),
assert(useMaterial3 != null),
// COLOR // COLOR
assert(colorScheme != null), assert(colorScheme != null),
assert(primaryColor != null), assert(primaryColor != null),
...@@ -1078,6 +1083,31 @@ class ThemeData with Diagnosticable { ...@@ -1078,6 +1083,31 @@ class ThemeData with Diagnosticable {
/// {@endtemplate} /// {@endtemplate}
final VisualDensity visualDensity; final VisualDensity visualDensity;
/// A temporary flag used to opt-in to new Material 3 features.
///
/// If true, then components that have been migrated to Material 3 will
/// start using new colors, typography and other features of Material 3.
/// If false, they will use the Material 2 look and feel.
///
/// Currently no components have been migrated to support Material 3.
/// As they are updated to include Material 3 support this documentation
/// will be modified to indicate exactly what widgets this flag will affect.
///
/// During the migration to Material 3, turning this on may yield
/// inconsistent look and feel in your app. Some components will be migrated
/// before others and typography changes will be coming in stages.
///
/// [useMaterial3] defaults to false. After all the migrated components
/// have landed on stable, we will change this to be true by default. After
/// that change has landed on stable, we will deprecate this flag and remove
/// all uses of it. Everything will use the Material 3 look and feel at
/// that point.
///
/// See also:
///
/// * [Material Design 3](https://m3.material.io/).
final bool useMaterial3;
// COLOR // COLOR
/// A set of twelve colors that can be used to configure the /// A set of twelve colors that can be used to configure the
...@@ -1486,6 +1516,7 @@ class ThemeData with Diagnosticable { ...@@ -1486,6 +1516,7 @@ class ThemeData with Diagnosticable {
ScrollbarThemeData? scrollbarTheme, ScrollbarThemeData? scrollbarTheme,
InteractiveInkFeatureFactory? splashFactory, InteractiveInkFeatureFactory? splashFactory,
VisualDensity? visualDensity, VisualDensity? visualDensity,
bool? useMaterial3,
// COLOR // COLOR
// [colorScheme] is the preferred way to configure colors. The other color // [colorScheme] is the preferred way to configure colors. The other color
// properties will gradually be phased out, see // properties will gradually be phased out, see
...@@ -1632,6 +1663,7 @@ class ThemeData with Diagnosticable { ...@@ -1632,6 +1663,7 @@ class ThemeData with Diagnosticable {
scrollbarTheme: scrollbarTheme ?? this.scrollbarTheme, scrollbarTheme: scrollbarTheme ?? this.scrollbarTheme,
splashFactory: splashFactory ?? this.splashFactory, splashFactory: splashFactory ?? this.splashFactory,
visualDensity: visualDensity ?? this.visualDensity, visualDensity: visualDensity ?? this.visualDensity,
useMaterial3: useMaterial3 ?? this.useMaterial3,
// COLOR // COLOR
colorScheme: (colorScheme ?? this.colorScheme).copyWith(brightness: brightness), colorScheme: (colorScheme ?? this.colorScheme).copyWith(brightness: brightness),
primaryColor: primaryColor ?? this.primaryColor, primaryColor: primaryColor ?? this.primaryColor,
...@@ -1800,6 +1832,7 @@ class ThemeData with Diagnosticable { ...@@ -1800,6 +1832,7 @@ class ThemeData with Diagnosticable {
scrollbarTheme: ScrollbarThemeData.lerp(a.scrollbarTheme, b.scrollbarTheme, t), scrollbarTheme: ScrollbarThemeData.lerp(a.scrollbarTheme, b.scrollbarTheme, t),
splashFactory: t < 0.5 ? a.splashFactory : b.splashFactory, splashFactory: t < 0.5 ? a.splashFactory : b.splashFactory,
visualDensity: VisualDensity.lerp(a.visualDensity, b.visualDensity, t), visualDensity: VisualDensity.lerp(a.visualDensity, b.visualDensity, t),
useMaterial3: t < 0.5 ? a.useMaterial3 : b.useMaterial3,
// COLOR // COLOR
colorScheme: ColorScheme.lerp(a.colorScheme, b.colorScheme, t), colorScheme: ColorScheme.lerp(a.colorScheme, b.colorScheme, t),
primaryColor: Color.lerp(a.primaryColor, b.primaryColor, t)!, primaryColor: Color.lerp(a.primaryColor, b.primaryColor, t)!,
...@@ -1898,6 +1931,7 @@ class ThemeData with Diagnosticable { ...@@ -1898,6 +1931,7 @@ class ThemeData with Diagnosticable {
other.scrollbarTheme == scrollbarTheme && other.scrollbarTheme == scrollbarTheme &&
other.splashFactory == splashFactory && other.splashFactory == splashFactory &&
other.visualDensity == visualDensity && other.visualDensity == visualDensity &&
other.useMaterial3 == useMaterial3 &&
// COLOR // COLOR
other.colorScheme == colorScheme && other.colorScheme == colorScheme &&
other.primaryColor == primaryColor && other.primaryColor == primaryColor &&
...@@ -1993,6 +2027,7 @@ class ThemeData with Diagnosticable { ...@@ -1993,6 +2027,7 @@ class ThemeData with Diagnosticable {
scrollbarTheme, scrollbarTheme,
splashFactory, splashFactory,
visualDensity, visualDensity,
useMaterial3,
// COLOR // COLOR
colorScheme, colorScheme,
primaryColor, primaryColor,
...@@ -2088,6 +2123,7 @@ class ThemeData with Diagnosticable { ...@@ -2088,6 +2123,7 @@ class ThemeData with Diagnosticable {
properties.add(DiagnosticsProperty<ScrollbarThemeData>('scrollbarTheme', scrollbarTheme, defaultValue: defaultData.scrollbarTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<ScrollbarThemeData>('scrollbarTheme', scrollbarTheme, defaultValue: defaultData.scrollbarTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<InteractiveInkFeatureFactory>('splashFactory', splashFactory, defaultValue: defaultData.splashFactory, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<InteractiveInkFeatureFactory>('splashFactory', splashFactory, defaultValue: defaultData.splashFactory, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<VisualDensity>('visualDensity', visualDensity, defaultValue: defaultData.visualDensity, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<VisualDensity>('visualDensity', visualDensity, defaultValue: defaultData.visualDensity, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<bool>('useMaterial3', useMaterial3, defaultValue: defaultData.useMaterial3, level: DiagnosticLevel.debug));
// COLORS // COLORS
properties.add(DiagnosticsProperty<ColorScheme>('colorScheme', colorScheme, defaultValue: defaultData.colorScheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<ColorScheme>('colorScheme', colorScheme, defaultValue: defaultData.colorScheme, level: DiagnosticLevel.debug));
properties.add(ColorProperty('primaryColor', primaryColor, defaultValue: defaultData.primaryColor, level: DiagnosticLevel.debug)); properties.add(ColorProperty('primaryColor', primaryColor, defaultValue: defaultData.primaryColor, level: DiagnosticLevel.debug));
......
...@@ -298,6 +298,7 @@ void main() { ...@@ -298,6 +298,7 @@ void main() {
highlightColor: Colors.black, highlightColor: Colors.black,
splashColor: Colors.black, splashColor: Colors.black,
splashFactory: InkRipple.splashFactory, splashFactory: InkRipple.splashFactory,
useMaterial3: false,
selectedRowColor: Colors.black, selectedRowColor: Colors.black,
unselectedWidgetColor: Colors.black, unselectedWidgetColor: Colors.black,
disabledColor: Colors.black, disabledColor: Colors.black,
...@@ -396,6 +397,7 @@ void main() { ...@@ -396,6 +397,7 @@ void main() {
highlightColor: Colors.white, highlightColor: Colors.white,
splashColor: Colors.white, splashColor: Colors.white,
splashFactory: InkRipple.splashFactory, splashFactory: InkRipple.splashFactory,
useMaterial3: true,
selectedRowColor: Colors.white, selectedRowColor: Colors.white,
unselectedWidgetColor: Colors.white, unselectedWidgetColor: Colors.white,
disabledColor: Colors.white, disabledColor: Colors.white,
...@@ -478,6 +480,7 @@ void main() { ...@@ -478,6 +480,7 @@ void main() {
highlightColor: otherTheme.highlightColor, highlightColor: otherTheme.highlightColor,
splashColor: otherTheme.splashColor, splashColor: otherTheme.splashColor,
splashFactory: otherTheme.splashFactory, splashFactory: otherTheme.splashFactory,
useMaterial3: otherTheme.useMaterial3,
selectedRowColor: otherTheme.selectedRowColor, selectedRowColor: otherTheme.selectedRowColor,
unselectedWidgetColor: otherTheme.unselectedWidgetColor, unselectedWidgetColor: otherTheme.unselectedWidgetColor,
disabledColor: otherTheme.disabledColor, disabledColor: otherTheme.disabledColor,
...@@ -556,6 +559,7 @@ void main() { ...@@ -556,6 +559,7 @@ void main() {
expect(themeDataCopy.highlightColor, equals(otherTheme.highlightColor)); expect(themeDataCopy.highlightColor, equals(otherTheme.highlightColor));
expect(themeDataCopy.splashColor, equals(otherTheme.splashColor)); expect(themeDataCopy.splashColor, equals(otherTheme.splashColor));
expect(themeDataCopy.splashFactory, equals(otherTheme.splashFactory)); expect(themeDataCopy.splashFactory, equals(otherTheme.splashFactory));
expect(themeDataCopy.useMaterial3, equals(otherTheme.useMaterial3));
expect(themeDataCopy.selectedRowColor, equals(otherTheme.selectedRowColor)); expect(themeDataCopy.selectedRowColor, equals(otherTheme.selectedRowColor));
expect(themeDataCopy.unselectedWidgetColor, equals(otherTheme.unselectedWidgetColor)); expect(themeDataCopy.unselectedWidgetColor, equals(otherTheme.unselectedWidgetColor));
expect(themeDataCopy.disabledColor, equals(otherTheme.disabledColor)); expect(themeDataCopy.disabledColor, equals(otherTheme.disabledColor));
...@@ -667,6 +671,7 @@ void main() { ...@@ -667,6 +671,7 @@ void main() {
'scrollbarTheme', 'scrollbarTheme',
'splashFactory', 'splashFactory',
'visualDensity', 'visualDensity',
'useMaterial3',
// COLOR // COLOR
'colorScheme', 'colorScheme',
'primaryColor', 'primaryColor',
......
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