Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
f99f4728
Unverified
Commit
f99f4728
authored
Feb 18, 2023
by
Qun Cheng
Committed by
GitHub
Feb 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the deprecated accentColor from ThemeData (#120932)
Co-authored-by:
Qun Cheng
<
quncheng@google.com
>
parent
61045052
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
68 deletions
+4
-68
button_theme.dart
packages/flutter/lib/src/material/button_theme.dart
+1
-1
theme_data.dart
packages/flutter/lib/src/material/theme_data.dart
+3
-54
theme_data_test.dart
packages/flutter/test/material/theme_data_test.dart
+0
-13
No files found.
packages/flutter/lib/src/material/button_theme.dart
View file @
f99f4728
...
...
@@ -23,7 +23,7 @@ enum ButtonTextTheme {
/// Button text is black or white depending on [ThemeData.brightness].
normal
,
/// Button text is [
ThemeData.accentColor
].
/// Button text is [
ColorScheme.secondary
].
accent
,
/// Button text is based on [ThemeData.primaryColor].
...
...
packages/flutter/lib/src/material/theme_data.dart
View file @
f99f4728
...
...
@@ -381,13 +381,6 @@ class ThemeData with Diagnosticable {
ToggleButtonsThemeData
?
toggleButtonsTheme
,
TooltipThemeData
?
tooltipTheme
,
// DEPRECATED (newest deprecations at the bottom)
@Deprecated
(
'Use colorScheme.secondary instead. '
'For more information, consult the migration guide at '
'https://flutter.dev/docs/release/breaking-changes/theme-data-accent-properties#migration-guide. '
'This feature was deprecated after v2.3.0-0.1.pre.'
,
)
Color
?
accentColor
,
@Deprecated
(
'This "fix" is now enabled by default. '
'This feature was deprecated after v2.5.0-1.0.pre.'
,
...
...
@@ -478,7 +471,6 @@ class ThemeData with Diagnosticable {
primaryColor
??=
primarySurfaceColor
;
primaryColorBrightness
=
ThemeData
.
estimateBrightnessForColor
(
primarySurfaceColor
);
canvasColor
??=
colorScheme
.
background
;
accentColor
??=
colorScheme
.
secondary
;
scaffoldBackgroundColor
??=
colorScheme
.
background
;
bottomAppBarColor
??=
colorScheme
.
surface
;
cardColor
??=
colorScheme
.
surface
;
...
...
@@ -496,8 +488,7 @@ class ThemeData with Diagnosticable {
primaryColorLight
??=
isDark
?
Colors
.
grey
[
500
]!
:
primarySwatch
[
100
]!;
primaryColorDark
??=
isDark
?
Colors
.
black
:
primarySwatch
[
700
]!;
final
bool
primaryIsDark
=
estimatedPrimaryColorBrightness
==
Brightness
.
dark
;
toggleableActiveColor
??=
isDark
?
Colors
.
tealAccent
[
200
]!
:
(
accentColor
??
primarySwatch
[
600
]!);
accentColor
??=
isDark
?
Colors
.
tealAccent
[
200
]!
:
primarySwatch
[
500
]!;
toggleableActiveColor
??=
isDark
?
Colors
.
tealAccent
[
200
]!
:
(
colorScheme
?.
secondary
??
primarySwatch
[
600
]!);
focusColor
??=
isDark
?
Colors
.
white
.
withOpacity
(
0.12
)
:
Colors
.
black
.
withOpacity
(
0.12
);
hoverColor
??=
isDark
?
Colors
.
white
.
withOpacity
(
0.04
)
:
Colors
.
black
.
withOpacity
(
0.04
);
shadowColor
??=
Colors
.
black
;
...
...
@@ -510,7 +501,7 @@ class ThemeData with Diagnosticable {
colorScheme
??=
ColorScheme
.
fromSwatch
(
primarySwatch:
primarySwatch
,
primaryColorDark:
primaryColorDark
,
accentColor:
accentColor
,
accentColor:
isDark
?
Colors
.
tealAccent
[
200
]!
:
primarySwatch
[
500
]!
,
cardColor:
cardColor
,
backgroundColor:
isDark
?
Colors
.
grey
[
700
]!
:
primarySwatch
[
200
]!,
errorColor:
Colors
.
red
[
700
],
...
...
@@ -521,7 +512,7 @@ class ThemeData with Diagnosticable {
// Spec doesn't specify a dark theme secondaryHeaderColor, this is a guess.
secondaryHeaderColor
??=
isDark
?
Colors
.
grey
[
700
]!
:
primarySwatch
[
50
]!;
dialogBackgroundColor
??=
isDark
?
Colors
.
grey
[
800
]!
:
Colors
.
white
;
indicatorColor
??=
accentColor
==
primaryColor
?
Colors
.
white
:
accentColor
;
indicatorColor
??=
colorScheme
.
secondary
==
primaryColor
?
Colors
.
white
:
colorScheme
.
secondary
;
hintColor
??=
isDark
?
Colors
.
white60
:
Colors
.
black
.
withOpacity
(
0.6
);
// The default [buttonTheme] is here because it doesn't use the defaults for
// [disabledColor], [highlightColor], and [splashColor].
...
...
@@ -702,7 +693,6 @@ class ThemeData with Diagnosticable {
toggleButtonsTheme:
toggleButtonsTheme
,
tooltipTheme:
tooltipTheme
,
// DEPRECATED (newest deprecations at the bottom)
accentColor:
accentColor
,
fixTextFieldOutlineLabel:
fixTextFieldOutlineLabel
,
primaryColorBrightness:
primaryColorBrightness
,
androidOverscrollIndicator:
androidOverscrollIndicator
,
...
...
@@ -813,13 +803,6 @@ class ThemeData with Diagnosticable {
required
this
.
toggleButtonsTheme
,
required
this
.
tooltipTheme
,
// DEPRECATED (newest deprecations at the bottom)
@Deprecated
(
'Use colorScheme.secondary instead. '
'For more information, consult the migration guide at '
'https://flutter.dev/docs/release/breaking-changes/theme-data-accent-properties#migration-guide. '
'This feature was deprecated after v2.3.0-0.1.pre.'
,
)
Color
?
accentColor
,
@Deprecated
(
'This "fix" is now enabled by default. '
'This feature was deprecated after v2.5.0-1.0.pre.'
,
...
...
@@ -865,7 +848,6 @@ class ThemeData with Diagnosticable {
})
:
// DEPRECATED (newest deprecations at the bottom)
// should not be `required`, use getter pattern to avoid breakages.
_accentColor
=
accentColor
,
_fixTextFieldOutlineLabel
=
fixTextFieldOutlineLabel
,
_primaryColorBrightness
=
primaryColorBrightness
,
_toggleableActiveColor
=
toggleableActiveColor
,
...
...
@@ -875,7 +857,6 @@ class ThemeData with Diagnosticable {
_bottomAppBarColor
=
bottomAppBarColor
,
assert
(
toggleableActiveColor
!=
null
),
// DEPRECATED (newest deprecations at the bottom)
assert
(
accentColor
!=
null
),
assert
(
fixTextFieldOutlineLabel
!=
null
),
assert
(
primaryColorBrightness
!=
null
),
assert
(
errorColor
!=
null
),
...
...
@@ -926,7 +907,6 @@ class ThemeData with Diagnosticable {
primaryColor:
primarySurfaceColor
,
primaryColorBrightness:
ThemeData
.
estimateBrightnessForColor
(
primarySurfaceColor
),
canvasColor:
colorScheme
.
background
,
accentColor:
colorScheme
.
secondary
,
scaffoldBackgroundColor:
colorScheme
.
background
,
bottomAppBarColor:
colorScheme
.
surface
,
cardColor:
colorScheme
.
surface
,
...
...
@@ -1534,25 +1514,6 @@ class ThemeData with Diagnosticable {
// DEPRECATED (newest deprecations at the bottom)
/// Obsolete property that was originally used as the foreground
/// color for widgets (knobs, text, overscroll edge effect, etc).
///
/// The material library no longer uses this property. In most cases the
/// [colorScheme]'s [ColorScheme.secondary] property is now used instead.
///
/// Apps should migrate uses of this property to the theme's [colorScheme]
/// [ColorScheme.secondary] color. In cases where a color is needed that
/// contrasts well with the secondary color [ColorScheme.onSecondary]
/// can be used.
@Deprecated
(
'Use colorScheme.secondary instead. '
'For more information, consult the migration guide at '
'https://flutter.dev/docs/release/breaking-changes/theme-data-accent-properties#migration-guide. '
'This feature was deprecated after v2.3.0-0.1.pre.'
,
)
Color
get
accentColor
=>
_accentColor
!;
final
Color
?
_accentColor
;
/// An obsolete flag to allow apps to opt-out of a
/// [small fix](https://github.com/flutter/flutter/issues/54028) for the Y
/// coordinate of the floating label in a [TextField] [OutlineInputBorder].
...
...
@@ -1737,13 +1698,6 @@ class ThemeData with Diagnosticable {
ToggleButtonsThemeData
?
toggleButtonsTheme
,
TooltipThemeData
?
tooltipTheme
,
// DEPRECATED (newest deprecations at the bottom)
@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/theme-data-accent-properties#migration-guide. '
'This feature was deprecated after v2.3.0-0.1.pre.'
,
)
Color
?
accentColor
,
@Deprecated
(
'This "fix" is now enabled by default. '
'This feature was deprecated after v2.5.0-1.0.pre.'
,
...
...
@@ -1877,7 +1831,6 @@ class ThemeData with Diagnosticable {
toggleButtonsTheme:
toggleButtonsTheme
??
this
.
toggleButtonsTheme
,
tooltipTheme:
tooltipTheme
??
this
.
tooltipTheme
,
// DEPRECATED (newest deprecations at the bottom)
accentColor:
accentColor
??
_accentColor
,
fixTextFieldOutlineLabel:
fixTextFieldOutlineLabel
??
_fixTextFieldOutlineLabel
,
primaryColorBrightness:
primaryColorBrightness
??
_primaryColorBrightness
,
androidOverscrollIndicator:
androidOverscrollIndicator
??
this
.
androidOverscrollIndicator
,
...
...
@@ -2071,7 +2024,6 @@ class ThemeData with Diagnosticable {
toggleButtonsTheme:
ToggleButtonsThemeData
.
lerp
(
a
.
toggleButtonsTheme
,
b
.
toggleButtonsTheme
,
t
)!,
tooltipTheme:
TooltipThemeData
.
lerp
(
a
.
tooltipTheme
,
b
.
tooltipTheme
,
t
)!,
// DEPRECATED (newest deprecations at the bottom)
accentColor:
Color
.
lerp
(
a
.
accentColor
,
b
.
accentColor
,
t
),
fixTextFieldOutlineLabel:
t
<
0.5
?
a
.
fixTextFieldOutlineLabel
:
b
.
fixTextFieldOutlineLabel
,
primaryColorBrightness:
t
<
0.5
?
a
.
primaryColorBrightness
:
b
.
primaryColorBrightness
,
androidOverscrollIndicator:
t
<
0.5
?
a
.
androidOverscrollIndicator
:
b
.
androidOverscrollIndicator
,
...
...
@@ -2177,7 +2129,6 @@ class ThemeData with Diagnosticable {
other
.
toggleButtonsTheme
==
toggleButtonsTheme
&&
other
.
tooltipTheme
==
tooltipTheme
&&
// DEPRECATED (newest deprecations at the bottom)
other
.
accentColor
==
accentColor
&&
other
.
fixTextFieldOutlineLabel
==
fixTextFieldOutlineLabel
&&
other
.
primaryColorBrightness
==
primaryColorBrightness
&&
other
.
androidOverscrollIndicator
==
androidOverscrollIndicator
&&
...
...
@@ -2280,7 +2231,6 @@ class ThemeData with Diagnosticable {
toggleButtonsTheme
,
tooltipTheme
,
// DEPRECATED (newest deprecations at the bottom)
accentColor
,
fixTextFieldOutlineLabel
,
primaryColorBrightness
,
androidOverscrollIndicator
,
...
...
@@ -2385,7 +2335,6 @@ class ThemeData with Diagnosticable {
properties
.
add
(
DiagnosticsProperty
<
ToggleButtonsThemeData
>(
'toggleButtonsTheme'
,
toggleButtonsTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
TooltipThemeData
>(
'tooltipTheme'
,
tooltipTheme
,
level:
DiagnosticLevel
.
debug
));
// DEPRECATED (newest deprecations at the bottom)
properties
.
add
(
ColorProperty
(
'accentColor'
,
accentColor
,
defaultValue:
defaultData
.
accentColor
,
level:
DiagnosticLevel
.
debug
));
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
));
...
...
packages/flutter/test/material/theme_data_test.dart
View file @
f99f4728
...
...
@@ -186,7 +186,6 @@ void main() {
expect
(
theme
.
primaryColor
,
theme
.
colorScheme
.
primary
);
expect
(
theme
.
primaryColorBrightness
,
Brightness
.
dark
);
expect
(
theme
.
canvasColor
,
theme
.
colorScheme
.
background
);
expect
(
theme
.
accentColor
,
theme
.
colorScheme
.
secondary
);
expect
(
theme
.
scaffoldBackgroundColor
,
theme
.
colorScheme
.
background
);
expect
(
theme
.
bottomAppBarColor
,
theme
.
colorScheme
.
surface
);
expect
(
theme
.
cardColor
,
theme
.
colorScheme
.
surface
);
...
...
@@ -237,7 +236,6 @@ void main() {
expect
(
theme
.
primaryColor
,
theme
.
colorScheme
.
surface
);
expect
(
theme
.
primaryColorBrightness
,
Brightness
.
dark
);
expect
(
theme
.
canvasColor
,
theme
.
colorScheme
.
background
);
expect
(
theme
.
accentColor
,
theme
.
colorScheme
.
secondary
);
expect
(
theme
.
scaffoldBackgroundColor
,
theme
.
colorScheme
.
background
);
expect
(
theme
.
bottomAppBarColor
,
theme
.
colorScheme
.
surface
);
expect
(
theme
.
cardColor
,
theme
.
colorScheme
.
surface
);
...
...
@@ -285,7 +283,6 @@ void main() {
expect
(
theme
.
primaryColor
,
theme
.
colorScheme
.
primary
);
expect
(
theme
.
primaryColorBrightness
,
Brightness
.
dark
);
expect
(
theme
.
canvasColor
,
theme
.
colorScheme
.
background
);
expect
(
theme
.
accentColor
,
theme
.
colorScheme
.
secondary
);
expect
(
theme
.
scaffoldBackgroundColor
,
theme
.
colorScheme
.
background
);
expect
(
theme
.
bottomAppBarColor
,
theme
.
colorScheme
.
surface
);
expect
(
theme
.
cardColor
,
theme
.
colorScheme
.
surface
);
...
...
@@ -334,7 +331,6 @@ void main() {
expect
(
theme
.
primaryColor
,
theme
.
colorScheme
.
primary
);
expect
(
theme
.
primaryColorBrightness
,
Brightness
.
dark
);
expect
(
theme
.
canvasColor
,
theme
.
colorScheme
.
background
);
expect
(
theme
.
accentColor
,
theme
.
colorScheme
.
secondary
);
expect
(
theme
.
scaffoldBackgroundColor
,
theme
.
colorScheme
.
background
);
expect
(
theme
.
bottomAppBarColor
,
theme
.
colorScheme
.
surface
);
expect
(
theme
.
cardColor
,
theme
.
colorScheme
.
surface
);
...
...
@@ -383,7 +379,6 @@ void main() {
expect
(
theme
.
primaryColor
,
theme
.
colorScheme
.
surface
);
expect
(
theme
.
primaryColorBrightness
,
Brightness
.
dark
);
expect
(
theme
.
canvasColor
,
theme
.
colorScheme
.
background
);
expect
(
theme
.
accentColor
,
theme
.
colorScheme
.
secondary
);
expect
(
theme
.
scaffoldBackgroundColor
,
theme
.
colorScheme
.
background
);
expect
(
theme
.
bottomAppBarColor
,
theme
.
colorScheme
.
surface
);
expect
(
theme
.
cardColor
,
theme
.
colorScheme
.
surface
);
...
...
@@ -401,7 +396,6 @@ void main() {
expect
(
theme
.
brightness
,
equals
(
Brightness
.
light
));
expect
(
theme
.
primaryColor
,
equals
(
lightColors
.
primary
));
expect
(
theme
.
accentColor
,
equals
(
lightColors
.
secondary
));
expect
(
theme
.
cardColor
,
equals
(
lightColors
.
surface
));
expect
(
theme
.
backgroundColor
,
equals
(
lightColors
.
background
));
expect
(
theme
.
canvasColor
,
equals
(
lightColors
.
background
));
...
...
@@ -418,7 +412,6 @@ void main() {
expect
(
theme
.
brightness
,
equals
(
Brightness
.
dark
));
// in dark theme's the color used for main components is surface instead of primary
expect
(
theme
.
primaryColor
,
equals
(
darkColors
.
surface
));
expect
(
theme
.
accentColor
,
equals
(
darkColors
.
secondary
));
expect
(
theme
.
cardColor
,
equals
(
darkColors
.
surface
));
expect
(
theme
.
backgroundColor
,
equals
(
darkColors
.
background
));
expect
(
theme
.
canvasColor
,
equals
(
darkColors
.
background
));
...
...
@@ -808,7 +801,6 @@ void main() {
toggleButtonsTheme:
const
ToggleButtonsThemeData
(
textStyle:
TextStyle
(
color:
Colors
.
black
)),
tooltipTheme:
const
TooltipThemeData
(
height:
100
),
// DEPRECATED (newest deprecations at the bottom)
accentColor:
Colors
.
black
,
fixTextFieldOutlineLabel:
false
,
primaryColorBrightness:
Brightness
.
dark
,
androidOverscrollIndicator:
AndroidOverscrollIndicator
.
glow
,
...
...
@@ -927,7 +919,6 @@ void main() {
tooltipTheme:
const
TooltipThemeData
(
height:
100
),
// DEPRECATED (newest deprecations at the bottom)
accentColor:
Colors
.
white
,
fixTextFieldOutlineLabel:
true
,
primaryColorBrightness:
Brightness
.
light
,
androidOverscrollIndicator:
AndroidOverscrollIndicator
.
stretch
,
...
...
@@ -1029,7 +1020,6 @@ void main() {
tooltipTheme:
otherTheme
.
tooltipTheme
,
// DEPRECATED (newest deprecations at the bottom)
accentColor:
otherTheme
.
accentColor
,
fixTextFieldOutlineLabel:
otherTheme
.
fixTextFieldOutlineLabel
,
primaryColorBrightness:
otherTheme
.
primaryColorBrightness
,
androidOverscrollIndicator:
otherTheme
.
androidOverscrollIndicator
,
...
...
@@ -1132,7 +1122,6 @@ void main() {
expect
(
themeDataCopy
.
tooltipTheme
,
equals
(
otherTheme
.
tooltipTheme
));
// DEPRECATED (newest deprecations at the bottom)
expect
(
themeDataCopy
.
accentColor
,
equals
(
otherTheme
.
accentColor
));
expect
(
themeDataCopy
.
fixTextFieldOutlineLabel
,
equals
(
otherTheme
.
fixTextFieldOutlineLabel
));
expect
(
themeDataCopy
.
primaryColorBrightness
,
equals
(
otherTheme
.
primaryColorBrightness
));
expect
(
themeDataCopy
.
androidOverscrollIndicator
,
equals
(
otherTheme
.
androidOverscrollIndicator
));
...
...
@@ -1171,7 +1160,6 @@ void main() {
expect
(
theme
.
brightness
,
equals
(
Brightness
.
dark
));
expect
(
theme
.
colorScheme
.
brightness
,
equals
(
Brightness
.
dark
));
expect
(
theme
.
primaryColor
,
equals
(
lightColors
.
primary
));
expect
(
theme
.
accentColor
,
equals
(
lightColors
.
secondary
));
expect
(
theme
.
cardColor
,
equals
(
lightColors
.
surface
));
expect
(
theme
.
backgroundColor
,
equals
(
lightColors
.
background
));
expect
(
theme
.
canvasColor
,
equals
(
lightColors
.
background
));
...
...
@@ -1267,7 +1255,6 @@ void main() {
'toggleButtonsTheme'
,
'tooltipTheme'
,
// DEPRECATED (newest deprecations at the bottom)
'accentColor'
,
'fixTextFieldOutlineLabel'
,
'primaryColorBrightness'
,
'androidOverscrollIndicator'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment