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
Expand all
Show 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
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/theme_data_test.dart
View file @
ac745b3f
...
@@ -245,8 +245,30 @@ void main() {
...
@@ -245,8 +245,30 @@ void main() {
expect
(
expanded
.
maxHeight
,
equals
(
double
.
infinity
));
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
(
final
SliderThemeData
sliderTheme
=
SliderThemeData
.
fromPrimaryColors
(
primaryColor:
Colors
.
black
,
primaryColor:
Colors
.
black
,
primaryColorDark:
Colors
.
black
,
primaryColorDark:
Colors
.
black
,
...
@@ -640,4 +662,106 @@ void main() {
...
@@ -640,4 +662,106 @@ void main() {
expect
(
theme
.
errorColor
,
equals
(
lightColors
.
error
));
expect
(
theme
.
errorColor
,
equals
(
lightColors
.
error
));
expect
(
theme
.
applyElevationOverlayColor
,
isFalse
);
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