Unverified Commit ed0aed7d authored by Hans Muller's avatar Hans Muller Committed by GitHub

Removed the color field from AppBarTheme (#73732)

parent 1b1ec738
...@@ -29,8 +29,8 @@ class AppBarTheme with Diagnosticable { ...@@ -29,8 +29,8 @@ class AppBarTheme with Diagnosticable {
/// Creates a theme that can be used for [ThemeData.appBarTheme]. /// Creates a theme that can be used for [ThemeData.appBarTheme].
const AppBarTheme({ const AppBarTheme({
this.brightness, this.brightness,
this.color, Color? color,
this.backgroundColor, Color? backgroundColor,
this.foregroundColor, this.foregroundColor,
this.elevation, this.elevation,
this.shadowColor, this.shadowColor,
...@@ -43,7 +43,10 @@ class AppBarTheme with Diagnosticable { ...@@ -43,7 +43,10 @@ class AppBarTheme with Diagnosticable {
this.titleTextStyle, this.titleTextStyle,
this.systemOverlayStyle, this.systemOverlayStyle,
this.backwardsCompatibility, this.backwardsCompatibility,
}); }) : assert(
color == null || backgroundColor == null,
'The color and backgroundColor parameters mean the same thing. Only specify one.'),
backgroundColor = backgroundColor ?? color;
/// This property is obsolete, please use [systemOverlayStyle] instead. /// This property is obsolete, please use [systemOverlayStyle] instead.
/// ///
...@@ -65,10 +68,11 @@ class AppBarTheme with Diagnosticable { ...@@ -65,10 +68,11 @@ class AppBarTheme with Diagnosticable {
/// See also: /// See also:
/// ///
/// * [backgroundColor], which serves this same purpose /// * [backgroundColor], which serves this same purpose
/// as this property, but has a consistent name. /// as this property, but has a name that's consistent with
/// [AppBar.backgroundColor].
/// * [AppBar.backwardsCompatibility], which forces [AppBar] to depend /// * [AppBar.backwardsCompatibility], which forces [AppBar] to depend
/// on this obsolete property. /// on this obsolete property.
final Color? color; Color? get color => backgroundColor;
/// Overrides the default value of [AppBar.backgroundColor] in all /// Overrides the default value of [AppBar.backgroundColor] in all
/// descendant [AppBar] widgets. /// descendant [AppBar] widgets.
...@@ -79,7 +83,6 @@ class AppBarTheme with Diagnosticable { ...@@ -79,7 +83,6 @@ class AppBarTheme with Diagnosticable {
/// [AppBar.foregroundColor] in all descendant widgets. /// [AppBar.foregroundColor] in all descendant widgets.
final Color? backgroundColor; final Color? backgroundColor;
/// Overrides the default value of [AppBar.foregroundColor] in all /// Overrides the default value of [AppBar.foregroundColor] in all
/// descendant widgets. /// descendant widgets.
/// ///
...@@ -185,10 +188,12 @@ class AppBarTheme with Diagnosticable { ...@@ -185,10 +188,12 @@ class AppBarTheme with Diagnosticable {
SystemUiOverlayStyle? systemOverlayStyle, SystemUiOverlayStyle? systemOverlayStyle,
bool? backwardsCompatibility, bool? backwardsCompatibility,
}) { }) {
assert(
color == null || backgroundColor == null,
'The color and backgroundColor parameters mean the same thing. Only specify one.');
return AppBarTheme( return AppBarTheme(
brightness: brightness ?? this.brightness, brightness: brightness ?? this.brightness,
color: color ?? this.color, backgroundColor: backgroundColor ?? color ?? this.backgroundColor,
backgroundColor: backgroundColor ?? this.backgroundColor,
foregroundColor: foregroundColor ?? this.foregroundColor, foregroundColor: foregroundColor ?? this.foregroundColor,
elevation: elevation ?? this.elevation, elevation: elevation ?? this.elevation,
shadowColor: shadowColor ?? this.shadowColor, shadowColor: shadowColor ?? this.shadowColor,
...@@ -218,7 +223,6 @@ class AppBarTheme with Diagnosticable { ...@@ -218,7 +223,6 @@ class AppBarTheme with Diagnosticable {
assert(t != null); assert(t != null);
return AppBarTheme( return AppBarTheme(
brightness: t < 0.5 ? a?.brightness : b?.brightness, brightness: t < 0.5 ? a?.brightness : b?.brightness,
color: Color.lerp(a?.color, b?.color, t),
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t), backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
foregroundColor: Color.lerp(a?.foregroundColor, b?.foregroundColor, t), foregroundColor: Color.lerp(a?.foregroundColor, b?.foregroundColor, t),
elevation: lerpDouble(a?.elevation, b?.elevation, t), elevation: lerpDouble(a?.elevation, b?.elevation, t),
...@@ -239,7 +243,6 @@ class AppBarTheme with Diagnosticable { ...@@ -239,7 +243,6 @@ class AppBarTheme with Diagnosticable {
int get hashCode { int get hashCode {
return hashValues( return hashValues(
brightness, brightness,
color,
backgroundColor, backgroundColor,
foregroundColor, foregroundColor,
elevation, elevation,
...@@ -264,7 +267,6 @@ class AppBarTheme with Diagnosticable { ...@@ -264,7 +267,6 @@ class AppBarTheme with Diagnosticable {
return false; return false;
return other is AppBarTheme return other is AppBarTheme
&& other.brightness == brightness && other.brightness == brightness
&& other.color == color
&& other.backgroundColor == backgroundColor && other.backgroundColor == backgroundColor
&& other.foregroundColor == foregroundColor && other.foregroundColor == foregroundColor
&& other.elevation == elevation && other.elevation == elevation
...@@ -284,7 +286,6 @@ class AppBarTheme with Diagnosticable { ...@@ -284,7 +286,6 @@ class AppBarTheme with Diagnosticable {
void debugFillProperties(DiagnosticPropertiesBuilder properties) { void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<Brightness>('brightness', brightness, defaultValue: null)); properties.add(DiagnosticsProperty<Brightness>('brightness', brightness, defaultValue: null));
properties.add(ColorProperty('color', color, defaultValue: null));
properties.add(ColorProperty('backgroundColor', backgroundColor, defaultValue: null)); properties.add(ColorProperty('backgroundColor', backgroundColor, defaultValue: null));
properties.add(ColorProperty('foregroundColor', foregroundColor, defaultValue: null)); properties.add(ColorProperty('foregroundColor', foregroundColor, defaultValue: null));
properties.add(DiagnosticsProperty<double>('elevation', elevation, defaultValue: null)); properties.add(DiagnosticsProperty<double>('elevation', elevation, defaultValue: null));
......
...@@ -442,7 +442,7 @@ void main() { ...@@ -442,7 +442,7 @@ void main() {
const AppBarTheme( const AppBarTheme(
backwardsCompatibility: false, backwardsCompatibility: false,
brightness: Brightness.dark, brightness: Brightness.dark,
color: Color(0xff000001), backgroundColor: Color(0xff000001),
elevation: 8.0, elevation: 8.0,
shadowColor: Color(0xff000002), shadowColor: Color(0xff000002),
centerTitle: true, centerTitle: true,
...@@ -456,7 +456,7 @@ void main() { ...@@ -456,7 +456,7 @@ void main() {
expect(description, <String>[ expect(description, <String>[
'brightness: Brightness.dark', 'brightness: Brightness.dark',
'color: Color(0xff000001)', 'backgroundColor: Color(0xff000001)',
'elevation: 8.0', 'elevation: 8.0',
'shadowColor: Color(0xff000002)', 'shadowColor: Color(0xff000002)',
'centerTitle: true', 'centerTitle: true',
......
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