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
223f8ed6
Unverified
Commit
223f8ed6
authored
Nov 08, 2021
by
Pierre-Louis
Committed by
GitHub
Nov 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reland "Refactor ThemeData (#91497)" (part 2) (#92970)
parent
58409c19
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
69 deletions
+74
-69
theme_data.dart
packages/flutter/lib/src/material/theme_data.dart
+74
-69
No files found.
packages/flutter/lib/src/material/theme_data.dart
View file @
223f8ed6
...
...
@@ -362,10 +362,32 @@ class ThemeData with Diagnosticable {
)
bool
?
fixTextFieldOutlineLabel
,
})
{
// GENERAL CONFIGURATION
applyElevationOverlayColor
??=
false
;
cupertinoOverrideTheme
=
cupertinoOverrideTheme
?.
noDefault
();
inputDecorationTheme
??=
const
InputDecorationTheme
();
platform
??=
defaultTargetPlatform
;
switch
(
platform
)
{
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
iOS
:
materialTapTargetSize
??=
MaterialTapTargetSize
.
padded
;
break
;
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
windows
:
materialTapTargetSize
??=
MaterialTapTargetSize
.
shrinkWrap
;
break
;
}
pageTransitionsTheme
??=
const
PageTransitionsTheme
();
scrollbarTheme
??=
const
ScrollbarThemeData
();
splashFactory
??=
InkSplash
.
splashFactory
;
visualDensity
??=
VisualDensity
.
adaptivePlatformDensity
;
// COLOR
assert
(
colorScheme
?.
brightness
==
null
||
brightness
==
null
||
colorScheme
!.
brightness
==
brightness
);
final
Brightness
_brightness
=
brightness
??
colorScheme
?.
brightness
??
Brightness
.
light
;
final
bool
isDark
=
_brightness
==
Brightness
.
dark
;
visualDensity
??=
VisualDensity
.
adaptivePlatformDensity
;
primarySwatch
??=
Colors
.
blue
;
primaryColor
??=
isDark
?
Colors
.
grey
[
900
]!
:
primarySwatch
;
primaryColorBrightness
??=
estimateBrightnessForColor
(
primaryColor
);
...
...
@@ -376,13 +398,14 @@ class ThemeData with Diagnosticable {
accentColor
??=
isDark
?
Colors
.
tealAccent
[
200
]!
:
primarySwatch
[
500
]!;
accentColorBrightness
??=
estimateBrightnessForColor
(
accentColor
);
final
bool
accentIsDark
=
accentColorBrightness
==
Brightness
.
dark
;
canvasColor
??=
isDark
?
Colors
.
grey
[
850
]!
:
Colors
.
grey
[
50
]!;
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
;
canvasColor
??=
isDark
?
Colors
.
grey
[
850
]!
:
Colors
.
grey
[
50
]!;
scaffoldBackgroundColor
??=
canvasColor
;
bottomAppBarColor
??=
isDark
?
Colors
.
grey
[
800
]!
:
Colors
.
white
;
cardColor
??=
isDark
?
Colors
.
grey
[
800
]!
:
Colors
.
white
;
dividerColor
??=
isDark
?
const
Color
(
0x1FFFFFFF
)
:
const
Color
(
0x1F000000
);
// Create a ColorScheme that is backwards compatible as possible
// with the existing default ThemeData color values.
colorScheme
??=
ColorScheme
.
fromSwatch
(
...
...
@@ -394,60 +417,21 @@ class ThemeData with Diagnosticable {
errorColor:
errorColor
,
brightness:
_brightness
,
);
splashFactory
??=
InkSplash
.
splashFactory
;
selectedRowColor
??=
Colors
.
grey
[
100
]!;
unselectedWidgetColor
??=
isDark
?
Colors
.
white70
:
Colors
.
black54
;
// Spec doesn't specify a dark theme secondaryHeaderColor, this is a guess.
secondaryHeaderColor
??=
isDark
?
Colors
.
grey
[
700
]!
:
primarySwatch
[
50
]!;
textSelectionColor
??=
isDark
?
accentColor
:
primarySwatch
[
200
]!;
cursorColor
=
cursorColor
??
const
Color
.
fromRGBO
(
66
,
133
,
244
,
1.0
);
textSelectionHandleColor
??=
isDark
?
Colors
.
tealAccent
[
400
]!
:
primarySwatch
[
300
]!;
backgroundColor
??=
isDark
?
Colors
.
grey
[
700
]!
:
primarySwatch
[
200
]!;
dialogBackgroundColor
??=
isDark
?
Colors
.
grey
[
800
]!
:
Colors
.
white
;
indicatorColor
??=
accentColor
==
primaryColor
?
Colors
.
white
:
accentColor
;
hintColor
??=
isDark
?
Colors
.
white60
:
Colors
.
black
.
withOpacity
(
0.6
);
errorColor
??=
Colors
.
red
[
700
]!;
inputDecorationTheme
??=
const
InputDecorationTheme
();
pageTransitionsTheme
??=
const
PageTransitionsTheme
();
primaryIconTheme
??=
primaryIsDark
?
const
IconThemeData
(
color:
Colors
.
white
)
:
const
IconThemeData
(
color:
Colors
.
black
);
accentIconTheme
??=
accentIsDark
?
const
IconThemeData
(
color:
Colors
.
white
)
:
const
IconThemeData
(
color:
Colors
.
black
);
iconTheme
??=
isDark
?
const
IconThemeData
(
color:
Colors
.
white
)
:
const
IconThemeData
(
color:
Colors
.
black87
);
platform
??=
defaultTargetPlatform
;
typography
??=
Typography
.
material2014
(
platform:
platform
);
TextTheme
defaultTextTheme
=
isDark
?
typography
.
white
:
typography
.
black
;
TextTheme
defaultPrimaryTextTheme
=
primaryIsDark
?
typography
.
white
:
typography
.
black
;
TextTheme
defaultAccentTextTheme
=
accentIsDark
?
typography
.
white
:
typography
.
black
;
if
(
fontFamily
!=
null
)
{
defaultTextTheme
=
defaultTextTheme
.
apply
(
fontFamily:
fontFamily
);
defaultPrimaryTextTheme
=
defaultPrimaryTextTheme
.
apply
(
fontFamily:
fontFamily
);
defaultAccentTextTheme
=
defaultAccentTextTheme
.
apply
(
fontFamily:
fontFamily
);
}
textTheme
=
defaultTextTheme
.
merge
(
textTheme
);
primaryTextTheme
=
defaultPrimaryTextTheme
.
merge
(
primaryTextTheme
);
accentTextTheme
=
defaultAccentTextTheme
.
merge
(
accentTextTheme
);
switch
(
platform
)
{
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
iOS
:
materialTapTargetSize
??=
MaterialTapTargetSize
.
padded
;
break
;
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
windows
:
materialTapTargetSize
??=
MaterialTapTargetSize
.
shrinkWrap
;
break
;
}
applyElevationOverlayColor
??=
false
;
// Used as the default color (fill color) for RaisedButtons. Computing the
// default for ButtonThemeData for the sake of backwards compatibility.
buttonColor
??=
isDark
?
primarySwatch
[
600
]!
:
Colors
.
grey
[
300
]!;
focusColor
??=
isDark
?
Colors
.
white
.
withOpacity
(
0.12
)
:
Colors
.
black
.
withOpacity
(
0.12
);
hoverColor
??=
isDark
?
Colors
.
white
.
withOpacity
(
0.04
)
:
Colors
.
black
.
withOpacity
(
0.04
);
// The default [buttonTheme] is here because it doesn't use the defaults for
// [disabledColor], [highlightColor], and [splashColor].
buttonTheme
??=
ButtonThemeData
(
colorScheme:
colorScheme
,
buttonColor:
buttonColor
,
// Defaults to the fill color for RaisedButtons for backwards compatibility.
buttonColor:
buttonColor
??
(
isDark
?
primarySwatch
[
600
]!
:
Colors
.
grey
[
300
]!),
disabledColor:
disabledColor
,
focusColor:
focusColor
,
hoverColor:
hoverColor
,
...
...
@@ -455,50 +439,71 @@ class ThemeData with Diagnosticable {
splashColor:
splashColor
,
materialTapTargetSize:
materialTapTargetSize
,
);
toggleButtonsTheme
??=
const
ToggleButtonsThemeData
();
disabledColor
??=
isDark
?
Colors
.
white38
:
Colors
.
black38
;
highlightColor
??=
isDark
?
_kDarkThemeHighlightColor
:
_kLightThemeHighlightColor
;
splashColor
??=
isDark
?
_kDarkThemeSplashColor
:
_kLightThemeSplashColor
;
sliderTheme
??=
const
SliderThemeData
();
tabBarTheme
??=
const
TabBarTheme
();
tooltipTheme
??=
const
TooltipThemeData
();
// TYPOGRAPHY & ICONOGRAPHY
typography
??=
Typography
.
material2014
(
platform:
platform
);
TextTheme
defaultTextTheme
=
isDark
?
typography
.
white
:
typography
.
black
;
TextTheme
defaultPrimaryTextTheme
=
primaryIsDark
?
typography
.
white
:
typography
.
black
;
TextTheme
defaultAccentTextTheme
=
accentIsDark
?
typography
.
white
:
typography
.
black
;
if
(
fontFamily
!=
null
)
{
defaultTextTheme
=
defaultTextTheme
.
apply
(
fontFamily:
fontFamily
);
defaultPrimaryTextTheme
=
defaultPrimaryTextTheme
.
apply
(
fontFamily:
fontFamily
);
defaultAccentTextTheme
=
defaultAccentTextTheme
.
apply
(
fontFamily:
fontFamily
);
}
textTheme
=
defaultTextTheme
.
merge
(
textTheme
);
primaryTextTheme
=
defaultPrimaryTextTheme
.
merge
(
primaryTextTheme
);
iconTheme
??=
isDark
?
const
IconThemeData
(
color:
Colors
.
white
)
:
const
IconThemeData
(
color:
Colors
.
black87
);
primaryIconTheme
??=
primaryIsDark
?
const
IconThemeData
(
color:
Colors
.
white
)
:
const
IconThemeData
(
color:
Colors
.
black
);
// COMPONENT THEMES
appBarTheme
??=
const
AppBarTheme
();
scrollbarTheme
??=
const
Scrollba
rThemeData
();
bannerTheme
??=
const
MaterialBanne
rThemeData
();
bottomAppBarTheme
??=
const
BottomAppBarTheme
();
bottomNavigationBarTheme
??=
const
BottomNavigationBarThemeData
();
bottomSheetTheme
??=
const
BottomSheetThemeData
();
buttonBarTheme
??=
const
ButtonBarThemeData
();
cardTheme
??=
const
CardTheme
();
chipTheme
??=
ChipThemeData
.
fromDefaults
(
secondaryColor:
isDark
?
Colors
.
tealAccent
[
200
]!
:
primaryColor
,
brightness:
colorScheme
.
brightness
,
labelStyle:
textTheme
.
bodyText1
!,
);
checkboxTheme
??=
const
CheckboxThemeData
();
dataTableTheme
??=
const
DataTableThemeData
();
dialogTheme
??=
const
DialogTheme
();
dividerTheme
??=
const
DividerThemeData
();
drawerTheme
??=
const
DrawerThemeData
();
elevatedButtonTheme
??=
const
ElevatedButtonThemeData
();
floatingActionButtonTheme
??=
const
FloatingActionButtonThemeData
();
listTileTheme
??=
const
ListTileThemeData
();
navigationBarTheme
??=
const
NavigationBarThemeData
();
navigationRailTheme
??=
const
NavigationRailThemeData
();
cupertinoOverrideTheme
=
cupertinoOverrideTheme
?.
noDefault
();
snackBarTheme
??=
const
SnackBarThemeData
();
bottomSheetTheme
??=
const
BottomSheetThemeData
();
popupMenuTheme
??=
const
PopupMenuThemeData
();
bannerTheme
??=
const
MaterialBannerThemeData
();
dividerTheme
??=
const
DividerThemeData
();
buttonBarTheme
??=
const
ButtonBarThemeData
();
bottomNavigationBarTheme
??=
const
BottomNavigationBarThemeData
();
timePickerTheme
??=
const
TimePickerThemeData
();
textButtonTheme
??=
const
TextButtonThemeData
();
elevatedButtonTheme
??=
const
ElevatedButtonThemeData
();
outlinedButtonTheme
??=
const
OutlinedButtonThemeData
();
textSelectionTheme
??=
const
TextSelectionThemeData
();
dataTableTheme
??=
const
DataTableThemeData
();
checkboxTheme
??=
const
CheckboxThemeData
();
popupMenuTheme
??=
const
PopupMenuThemeData
();
progressIndicatorTheme
??=
const
ProgressIndicatorThemeData
();
radioTheme
??=
const
RadioThemeData
();
sliderTheme
??=
const
SliderThemeData
();
snackBarTheme
??=
const
SnackBarThemeData
();
switchTheme
??=
const
SwitchThemeData
();
progressIndicatorTheme
??=
const
ProgressIndicatorThemeData
();
drawerTheme
??=
const
DrawerThemeData
();
listTileTheme
??=
const
ListTileThemeData
();
tabBarTheme
??=
const
TabBarTheme
();
textButtonTheme
??=
const
TextButtonThemeData
();
textSelectionTheme
??=
const
TextSelectionThemeData
();
timePickerTheme
??=
const
TimePickerThemeData
();
toggleButtonsTheme
??=
const
ToggleButtonsThemeData
();
tooltipTheme
??=
const
TooltipThemeData
();
fixTextFieldOutlineLabel
??=
true
;
// DEPRECATED (newest deprecations at the bottom)
useTextSelectionTheme
??=
true
;
textSelectionColor
??=
isDark
?
accentColor
:
primarySwatch
[
200
]!;
cursorColor
=
cursorColor
??
const
Color
.
fromRGBO
(
66
,
133
,
244
,
1.0
);
textSelectionHandleColor
??=
isDark
?
Colors
.
tealAccent
[
400
]!
:
primarySwatch
[
300
]!;
accentTextTheme
=
defaultAccentTextTheme
.
merge
(
accentTextTheme
);
accentIconTheme
??=
accentIsDark
?
const
IconThemeData
(
color:
Colors
.
white
)
:
const
IconThemeData
(
color:
Colors
.
black
);
buttonColor
??=
isDark
?
primarySwatch
[
600
]!
:
Colors
.
grey
[
300
]!;
fixTextFieldOutlineLabel
??=
true
;
return
ThemeData
.
raw
(
// GENERAL CONFIGURATION
...
...
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