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
ac745b3f
Unverified
Commit
ac745b3f
authored
Oct 14, 2021
by
Darren Austin
Committed by
GitHub
Oct 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ThemeData property cleanup. (#91774)
parent
acab6dcc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
143 additions
and
13 deletions
+143
-13
theme_data.dart
packages/flutter/lib/src/material/theme_data.dart
+18
-12
theme_data_test.dart
packages/flutter/test/material/theme_data_test.dart
+125
-1
No files found.
packages/flutter/lib/src/material/theme_data.dart
View file @
ac745b3f
...
...
@@ -1726,8 +1726,8 @@ class ThemeData with Diagnosticable {
unselectedWidgetColor:
Color
.
lerp
(
a
.
unselectedWidgetColor
,
b
.
unselectedWidgetColor
,
t
)!,
disabledColor:
Color
.
lerp
(
a
.
disabledColor
,
b
.
disabledColor
,
t
)!,
buttonTheme:
t
<
0.5
?
a
.
buttonTheme
:
b
.
buttonTheme
,
toggleButtonsTheme:
ToggleButtonsThemeData
.
lerp
(
a
.
toggleButtonsTheme
,
b
.
toggleButtonsTheme
,
t
)!,
buttonColor:
Color
.
lerp
(
a
.
buttonColor
,
b
.
buttonColor
,
t
)!,
toggleButtonsTheme:
ToggleButtonsThemeData
.
lerp
(
a
.
toggleButtonsTheme
,
b
.
toggleButtonsTheme
,
t
)!,
secondaryHeaderColor:
Color
.
lerp
(
a
.
secondaryHeaderColor
,
b
.
secondaryHeaderColor
,
t
)!,
textSelectionColor:
Color
.
lerp
(
a
.
textSelectionColor
,
b
.
textSelectionColor
,
t
)!,
cursorColor:
Color
.
lerp
(
a
.
cursorColor
,
b
.
cursorColor
,
t
)!,
...
...
@@ -1775,7 +1775,7 @@ class ThemeData with Diagnosticable {
textButtonTheme:
TextButtonThemeData
.
lerp
(
a
.
textButtonTheme
,
b
.
textButtonTheme
,
t
)!,
elevatedButtonTheme:
ElevatedButtonThemeData
.
lerp
(
a
.
elevatedButtonTheme
,
b
.
elevatedButtonTheme
,
t
)!,
outlinedButtonTheme:
OutlinedButtonThemeData
.
lerp
(
a
.
outlinedButtonTheme
,
b
.
outlinedButtonTheme
,
t
)!,
textSelectionTheme:
TextSelectionThemeData
.
lerp
(
a
.
textSelectionTheme
,
b
.
textSelectionTheme
,
t
)!,
textSelectionTheme:
TextSelectionThemeData
.
lerp
(
a
.
textSelectionTheme
,
b
.
textSelectionTheme
,
t
)!,
dataTableTheme:
DataTableThemeData
.
lerp
(
a
.
dataTableTheme
,
b
.
dataTableTheme
,
t
),
checkboxTheme:
CheckboxThemeData
.
lerp
(
a
.
checkboxTheme
,
b
.
checkboxTheme
,
t
),
radioTheme:
RadioThemeData
.
lerp
(
a
.
radioTheme
,
b
.
radioTheme
,
t
),
...
...
@@ -1802,14 +1802,16 @@ class ThemeData with Diagnosticable {
&&
other
.
primaryColorBrightness
==
primaryColorBrightness
&&
other
.
primaryColorLight
==
primaryColorLight
&&
other
.
primaryColorDark
==
primaryColorDark
&&
other
.
canvasColor
==
canvasColor
&&
other
.
shadowColor
==
shadowColor
&&
other
.
accentColor
==
accentColor
&&
other
.
accentColorBrightness
==
accentColorBrightness
&&
other
.
canvasColor
==
canvasColor
&&
other
.
scaffoldBackgroundColor
==
scaffoldBackgroundColor
&&
other
.
bottomAppBarColor
==
bottomAppBarColor
&&
other
.
cardColor
==
cardColor
&&
other
.
shadowColor
==
shadowColor
&&
other
.
dividerColor
==
dividerColor
&&
other
.
focusColor
==
focusColor
&&
other
.
hoverColor
==
hoverColor
&&
other
.
highlightColor
==
highlightColor
&&
other
.
splashColor
==
splashColor
&&
other
.
splashFactory
==
splashFactory
...
...
@@ -1890,10 +1892,10 @@ class ThemeData with Diagnosticable {
primaryColorBrightness
,
primaryColorLight
,
primaryColorDark
,
accentColor
,
accentColorBrightness
,
canvasColor
,
shadowColor
,
accentColor
,
accentColorBrightness
,
scaffoldBackgroundColor
,
bottomAppBarColor
,
cardColor
,
...
...
@@ -1909,7 +1911,6 @@ class ThemeData with Diagnosticable {
buttonTheme
,
buttonColor
,
toggleButtonsTheme
,
toggleableActiveColor
,
secondaryHeaderColor
,
textSelectionColor
,
cursorColor
,
...
...
@@ -1919,6 +1920,7 @@ class ThemeData with Diagnosticable {
indicatorColor
,
hintColor
,
errorColor
,
toggleableActiveColor
,
textTheme
,
primaryTextTheme
,
accentTextTheme
,
...
...
@@ -1975,10 +1977,12 @@ class ThemeData with Diagnosticable {
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
super
.
debugFillProperties
(
properties
);
final
ThemeData
defaultData
=
ThemeData
.
fallback
();
properties
.
add
(
DiagnosticsProperty
<
VisualDensity
>(
'visualDensity'
,
visualDensity
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
EnumProperty
<
TargetPlatform
>(
'platform'
,
platform
,
defaultValue:
defaultTargetPlatform
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
EnumProperty
<
Brightness
>(
'brightness'
,
brightness
,
defaultValue:
defaultData
.
brightness
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
ColorProperty
(
'primaryColor'
,
primaryColor
,
defaultValue:
defaultData
.
primaryColor
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
EnumProperty
<
Brightness
>(
'primaryColorBrightness'
,
primaryColorBrightness
,
defaultValue:
defaultData
.
primaryColorBrightness
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
ColorProperty
(
'primaryColorLight'
,
primaryColorLight
,
defaultValue:
defaultData
.
primaryColorLight
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
ColorProperty
(
'primaryColorDark'
,
primaryColorDark
,
defaultValue:
defaultData
.
primaryColorDark
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
ColorProperty
(
'accentColor'
,
accentColor
,
defaultValue:
defaultData
.
accentColor
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
EnumProperty
<
Brightness
>(
'accentColorBrightness'
,
accentColorBrightness
,
defaultValue:
defaultData
.
accentColorBrightness
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
ColorProperty
(
'canvasColor'
,
canvasColor
,
defaultValue:
defaultData
.
canvasColor
,
level:
DiagnosticLevel
.
debug
));
...
...
@@ -1991,6 +1995,7 @@ class ThemeData with Diagnosticable {
properties
.
add
(
ColorProperty
(
'hoverColor'
,
hoverColor
,
defaultValue:
defaultData
.
hoverColor
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
ColorProperty
(
'highlightColor'
,
highlightColor
,
defaultValue:
defaultData
.
highlightColor
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
ColorProperty
(
'splashColor'
,
splashColor
,
defaultValue:
defaultData
.
splashColor
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
InteractiveInkFeatureFactory
>(
'splashFactory'
,
splashFactory
,
defaultValue:
defaultData
.
splashFactory
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
ColorProperty
(
'selectedRowColor'
,
selectedRowColor
,
defaultValue:
defaultData
.
selectedRowColor
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
ColorProperty
(
'unselectedWidgetColor'
,
unselectedWidgetColor
,
defaultValue:
defaultData
.
unselectedWidgetColor
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
ColorProperty
(
'disabledColor'
,
disabledColor
,
defaultValue:
defaultData
.
disabledColor
,
level:
DiagnosticLevel
.
debug
));
...
...
@@ -2023,13 +2028,13 @@ class ThemeData with Diagnosticable {
properties
.
add
(
DiagnosticsProperty
<
bool
>(
'applyElevationOverlayColor'
,
applyElevationOverlayColor
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
PageTransitionsTheme
>(
'pageTransitionsTheme'
,
pageTransitionsTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
AppBarTheme
>(
'appBarTheme'
,
appBarTheme
,
defaultValue:
defaultData
.
appBarTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
ScrollbarThemeData
>(
'
S
crollbarTheme'
,
scrollbarTheme
,
defaultValue:
defaultData
.
scrollbarTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
ScrollbarThemeData
>(
'
s
crollbarTheme'
,
scrollbarTheme
,
defaultValue:
defaultData
.
scrollbarTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
BottomAppBarTheme
>(
'bottomAppBarTheme'
,
bottomAppBarTheme
,
defaultValue:
defaultData
.
bottomAppBarTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
ColorScheme
>(
'colorScheme'
,
colorScheme
,
defaultValue:
defaultData
.
colorScheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
DialogTheme
>(
'dialogTheme'
,
dialogTheme
,
defaultValue:
defaultData
.
dialogTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
FloatingActionButtonThemeData
>(
'floatingActionButtonTheme
Data
'
,
floatingActionButtonTheme
,
defaultValue:
defaultData
.
floatingActionButtonTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
FloatingActionButtonThemeData
>(
'floatingActionButtonTheme'
,
floatingActionButtonTheme
,
defaultValue:
defaultData
.
floatingActionButtonTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
NavigationBarThemeData
>(
'navigationBarTheme'
,
navigationBarTheme
,
defaultValue:
defaultData
.
navigationBarTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
NavigationRailThemeData
>(
'navigationRailTheme
Data
'
,
navigationRailTheme
,
defaultValue:
defaultData
.
navigationRailTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
NavigationRailThemeData
>(
'navigationRailTheme'
,
navigationRailTheme
,
defaultValue:
defaultData
.
navigationRailTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
Typography
>(
'typography'
,
typography
,
defaultValue:
defaultData
.
typography
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
NoDefaultCupertinoThemeData
>(
'cupertinoOverrideTheme'
,
cupertinoOverrideTheme
,
defaultValue:
defaultData
.
cupertinoOverrideTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
SnackBarThemeData
>(
'snackBarTheme'
,
snackBarTheme
,
defaultValue:
defaultData
.
snackBarTheme
,
level:
DiagnosticLevel
.
debug
));
...
...
@@ -2040,7 +2045,6 @@ class ThemeData with Diagnosticable {
properties
.
add
(
DiagnosticsProperty
<
ButtonBarThemeData
>(
'buttonBarTheme'
,
buttonBarTheme
,
defaultValue:
defaultData
.
buttonBarTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
TimePickerThemeData
>(
'timePickerTheme'
,
timePickerTheme
,
defaultValue:
defaultData
.
timePickerTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
TextSelectionThemeData
>(
'textSelectionTheme'
,
textSelectionTheme
,
defaultValue:
defaultData
.
textSelectionTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
TextSelectionThemeData
>(
'textSelectionTheme'
,
textSelectionTheme
,
defaultValue:
defaultData
.
textSelectionTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
BottomNavigationBarThemeData
>(
'bottomNavigationBarTheme'
,
bottomNavigationBarTheme
,
defaultValue:
defaultData
.
bottomNavigationBarTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
TextButtonThemeData
>(
'textButtonTheme'
,
textButtonTheme
,
defaultValue:
defaultData
.
textButtonTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
ElevatedButtonThemeData
>(
'elevatedButtonTheme'
,
elevatedButtonTheme
,
defaultValue:
defaultData
.
elevatedButtonTheme
,
level:
DiagnosticLevel
.
debug
));
...
...
@@ -2052,6 +2056,8 @@ class ThemeData with Diagnosticable {
properties
.
add
(
DiagnosticsProperty
<
ProgressIndicatorThemeData
>(
'progressIndicatorTheme'
,
progressIndicatorTheme
,
defaultValue:
defaultData
.
progressIndicatorTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
DrawerThemeData
>(
'drawerTheme'
,
drawerTheme
,
defaultValue:
defaultData
.
drawerTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
ListTileThemeData
>(
'listTileTheme'
,
listTileTheme
,
defaultValue:
defaultData
.
listTileTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
bool
>(
'fixTextFieldOutlineLabel'
,
fixTextFieldOutlineLabel
,
defaultValue:
true
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
bool
>(
'useTextSelectionTheme'
,
useTextSelectionTheme
,
defaultValue:
true
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
EnumProperty
<
AndroidOverscrollIndicator
>(
'androidOverscrollIndicator'
,
androidOverscrollIndicator
,
defaultValue:
null
,
level:
DiagnosticLevel
.
debug
));
}
}
...
...
packages/flutter/test/material/theme_data_test.dart
View file @
ac745b3f
...
...
@@ -245,8 +245,30 @@ void main() {
expect
(
expanded
.
maxHeight
,
equals
(
double
.
infinity
));
});
testWidgets
(
'ThemeData.copyWith correctly creates new ThemeData with all copied arguments'
,
(
WidgetTester
tester
)
async
{
test
(
'copyWith, ==, hashCode basics'
,
()
{
expect
(
ThemeData
(),
ThemeData
().
copyWith
());
expect
(
ThemeData
().
hashCode
,
ThemeData
().
copyWith
().
hashCode
);
});
test
(
'== and hashCode include focusColor and hoverColor'
,
()
{
// regression test for https://github.com/flutter/flutter/issues/91587
// Focus color and hover color are used in the default button theme, so
// use an empty one to ensure that just focus and hover colors are tested.
const
ButtonThemeData
buttonTheme
=
ButtonThemeData
();
final
ThemeData
focusColorBlack
=
ThemeData
(
focusColor:
Colors
.
black
,
buttonTheme:
buttonTheme
);
final
ThemeData
focusColorWhite
=
ThemeData
(
focusColor:
Colors
.
white
,
buttonTheme:
buttonTheme
);
expect
(
focusColorBlack
!=
focusColorWhite
,
true
);
expect
(
focusColorBlack
.
hashCode
!=
focusColorWhite
.
hashCode
,
true
);
final
ThemeData
hoverColorBlack
=
ThemeData
(
hoverColor:
Colors
.
black
,
buttonTheme:
buttonTheme
);
final
ThemeData
hoverColorWhite
=
ThemeData
(
hoverColor:
Colors
.
white
,
buttonTheme:
buttonTheme
);
expect
(
hoverColorBlack
!=
hoverColorWhite
,
true
);
expect
(
hoverColorBlack
.
hashCode
!=
hoverColorWhite
.
hashCode
,
true
);
});
testWidgets
(
'ThemeData.copyWith correctly creates new ThemeData with all copied arguments'
,
(
WidgetTester
tester
)
async
{
final
SliderThemeData
sliderTheme
=
SliderThemeData
.
fromPrimaryColors
(
primaryColor:
Colors
.
black
,
primaryColorDark:
Colors
.
black
,
...
...
@@ -640,4 +662,106 @@ void main() {
expect
(
theme
.
errorColor
,
equals
(
lightColors
.
error
));
expect
(
theme
.
applyElevationOverlayColor
,
isFalse
);
});
test
(
'ThemeData diagnostics include all properties'
,
()
{
// List of properties must match the properties in ThemeData.hashCode()
final
Set
<
String
>
expectedPropertyNames
=
<
String
>{
'visualDensity'
,
'primaryColor'
,
'primaryColorBrightness'
,
'primaryColorLight'
,
'primaryColorDark'
,
'canvasColor'
,
'shadowColor'
,
'accentColor'
,
'accentColorBrightness'
,
'scaffoldBackgroundColor'
,
'bottomAppBarColor'
,
'cardColor'
,
'dividerColor'
,
'focusColor'
,
'hoverColor'
,
'highlightColor'
,
'splashColor'
,
'splashFactory'
,
'selectedRowColor'
,
'unselectedWidgetColor'
,
'disabledColor'
,
'buttonTheme'
,
'buttonColor'
,
'toggleButtonsTheme'
,
'secondaryHeaderColor'
,
'textSelectionColor'
,
'cursorColor'
,
'textSelectionHandleColor'
,
'backgroundColor'
,
'dialogBackgroundColor'
,
'indicatorColor'
,
'hintColor'
,
'errorColor'
,
'toggleableActiveColor'
,
'textTheme'
,
'primaryTextTheme'
,
'accentTextTheme'
,
'inputDecorationTheme'
,
'iconTheme'
,
'primaryIconTheme'
,
'accentIconTheme'
,
'sliderTheme'
,
'tabBarTheme'
,
'tooltipTheme'
,
'cardTheme'
,
'chipTheme'
,
'platform'
,
'materialTapTargetSize'
,
'applyElevationOverlayColor'
,
'pageTransitionsTheme'
,
'appBarTheme'
,
'scrollbarTheme'
,
'bottomAppBarTheme'
,
'colorScheme'
,
'dialogTheme'
,
'floatingActionButtonTheme'
,
'navigationBarTheme'
,
'navigationRailTheme'
,
'typography'
,
'cupertinoOverrideTheme'
,
'snackBarTheme'
,
'bottomSheetTheme'
,
'popupMenuTheme'
,
'bannerTheme'
,
'dividerTheme'
,
'buttonBarTheme'
,
'bottomNavigationBarTheme'
,
'timePickerTheme'
,
'textButtonTheme'
,
'elevatedButtonTheme'
,
'outlinedButtonTheme'
,
'textSelectionTheme'
,
'dataTableTheme'
,
'checkboxTheme'
,
'radioTheme'
,
'switchTheme'
,
'progressIndicatorTheme'
,
'drawerTheme'
,
'listTileTheme'
,
'fixTextFieldOutlineLabel'
,
'useTextSelectionTheme'
,
'androidOverscrollIndicator'
,
};
final
DiagnosticPropertiesBuilder
properties
=
DiagnosticPropertiesBuilder
();
ThemeData
.
light
().
debugFillProperties
(
properties
);
final
List
<
String
>
propertyNameList
=
properties
.
properties
.
map
((
final
DiagnosticsNode
node
)
=>
node
.
name
)
.
whereType
<
String
>()
.
toList
();
final
Set
<
String
>
propertyNames
=
propertyNameList
.
toSet
();
// Ensure there are no duplicates.
expect
(
propertyNameList
.
length
,
propertyNames
.
length
);
// Ensure they are all there.
expect
(
propertyNames
,
expectedPropertyNames
);
});
}
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