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
7d098177
Unverified
Commit
7d098177
authored
Nov 19, 2021
by
Darren Austin
Committed by
GitHub
Nov 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added useMaterial3 flag to ThemeData. (#93434)
parent
99e85b1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
theme_data.dart
packages/flutter/lib/src/material/theme_data.dart
+36
-0
theme_data_test.dart
packages/flutter/test/material/theme_data_test.dart
+5
-0
No files found.
packages/flutter/lib/src/material/theme_data.dart
View file @
7d098177
...
...
@@ -231,6 +231,7 @@ class ThemeData with Diagnosticable {
ScrollbarThemeData
?
scrollbarTheme
,
InteractiveInkFeatureFactory
?
splashFactory
,
VisualDensity
?
visualDensity
,
bool
?
useMaterial3
,
// COLOR
// [colorScheme] is the preferred way to configure colors. The other color
// properties (as well as brightness, primaryColorBrightness, and primarySwatch)
...
...
@@ -387,6 +388,7 @@ class ThemeData with Diagnosticable {
scrollbarTheme
??=
const
ScrollbarThemeData
();
splashFactory
??=
InkSplash
.
splashFactory
;
visualDensity
??=
VisualDensity
.
adaptivePlatformDensity
;
useMaterial3
??=
false
;
// COLOR
assert
(
colorScheme
?.
brightness
==
null
||
brightness
==
null
||
colorScheme
!.
brightness
==
brightness
);
...
...
@@ -518,6 +520,7 @@ class ThemeData with Diagnosticable {
scrollbarTheme:
scrollbarTheme
,
splashFactory:
splashFactory
,
visualDensity:
visualDensity
,
useMaterial3:
useMaterial3
,
// COLOR
colorScheme:
colorScheme
,
primaryColor:
primaryColor
,
...
...
@@ -619,6 +622,7 @@ class ThemeData with Diagnosticable {
required
this
.
scrollbarTheme
,
required
this
.
splashFactory
,
required
this
.
visualDensity
,
required
this
.
useMaterial3
,
// COLOR
// [colorScheme] is the preferred way to configure colors. The other color
// properties will gradually be phased out, see
...
...
@@ -759,6 +763,7 @@ class ThemeData with Diagnosticable {
assert
(
scrollbarTheme
!=
null
),
assert
(
splashFactory
!=
null
),
assert
(
visualDensity
!=
null
),
assert
(
useMaterial3
!=
null
),
// COLOR
assert
(
colorScheme
!=
null
),
assert
(
primaryColor
!=
null
),
...
...
@@ -1078,6 +1083,31 @@ class ThemeData with Diagnosticable {
/// {@endtemplate}
final
VisualDensity
visualDensity
;
/// A temporary flag used to opt-in to new Material 3 features.
///
/// If true, then components that have been migrated to Material 3 will
/// start using new colors, typography and other features of Material 3.
/// If false, they will use the Material 2 look and feel.
///
/// Currently no components have been migrated to support Material 3.
/// As they are updated to include Material 3 support this documentation
/// will be modified to indicate exactly what widgets this flag will affect.
///
/// During the migration to Material 3, turning this on may yield
/// inconsistent look and feel in your app. Some components will be migrated
/// before others and typography changes will be coming in stages.
///
/// [useMaterial3] defaults to false. After all the migrated components
/// have landed on stable, we will change this to be true by default. After
/// that change has landed on stable, we will deprecate this flag and remove
/// all uses of it. Everything will use the Material 3 look and feel at
/// that point.
///
/// See also:
///
/// * [Material Design 3](https://m3.material.io/).
final
bool
useMaterial3
;
// COLOR
/// A set of twelve colors that can be used to configure the
...
...
@@ -1486,6 +1516,7 @@ class ThemeData with Diagnosticable {
ScrollbarThemeData
?
scrollbarTheme
,
InteractiveInkFeatureFactory
?
splashFactory
,
VisualDensity
?
visualDensity
,
bool
?
useMaterial3
,
// COLOR
// [colorScheme] is the preferred way to configure colors. The other color
// properties will gradually be phased out, see
...
...
@@ -1632,6 +1663,7 @@ class ThemeData with Diagnosticable {
scrollbarTheme:
scrollbarTheme
??
this
.
scrollbarTheme
,
splashFactory:
splashFactory
??
this
.
splashFactory
,
visualDensity:
visualDensity
??
this
.
visualDensity
,
useMaterial3:
useMaterial3
??
this
.
useMaterial3
,
// COLOR
colorScheme:
(
colorScheme
??
this
.
colorScheme
).
copyWith
(
brightness:
brightness
),
primaryColor:
primaryColor
??
this
.
primaryColor
,
...
...
@@ -1800,6 +1832,7 @@ class ThemeData with Diagnosticable {
scrollbarTheme:
ScrollbarThemeData
.
lerp
(
a
.
scrollbarTheme
,
b
.
scrollbarTheme
,
t
),
splashFactory:
t
<
0.5
?
a
.
splashFactory
:
b
.
splashFactory
,
visualDensity:
VisualDensity
.
lerp
(
a
.
visualDensity
,
b
.
visualDensity
,
t
),
useMaterial3:
t
<
0.5
?
a
.
useMaterial3
:
b
.
useMaterial3
,
// COLOR
colorScheme:
ColorScheme
.
lerp
(
a
.
colorScheme
,
b
.
colorScheme
,
t
),
primaryColor:
Color
.
lerp
(
a
.
primaryColor
,
b
.
primaryColor
,
t
)!,
...
...
@@ -1898,6 +1931,7 @@ class ThemeData with Diagnosticable {
other
.
scrollbarTheme
==
scrollbarTheme
&&
other
.
splashFactory
==
splashFactory
&&
other
.
visualDensity
==
visualDensity
&&
other
.
useMaterial3
==
useMaterial3
&&
// COLOR
other
.
colorScheme
==
colorScheme
&&
other
.
primaryColor
==
primaryColor
&&
...
...
@@ -1993,6 +2027,7 @@ class ThemeData with Diagnosticable {
scrollbarTheme
,
splashFactory
,
visualDensity
,
useMaterial3
,
// COLOR
colorScheme
,
primaryColor
,
...
...
@@ -2088,6 +2123,7 @@ class ThemeData with Diagnosticable {
properties
.
add
(
DiagnosticsProperty
<
ScrollbarThemeData
>(
'scrollbarTheme'
,
scrollbarTheme
,
defaultValue:
defaultData
.
scrollbarTheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
InteractiveInkFeatureFactory
>(
'splashFactory'
,
splashFactory
,
defaultValue:
defaultData
.
splashFactory
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
VisualDensity
>(
'visualDensity'
,
visualDensity
,
defaultValue:
defaultData
.
visualDensity
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
DiagnosticsProperty
<
bool
>(
'useMaterial3'
,
useMaterial3
,
defaultValue:
defaultData
.
useMaterial3
,
level:
DiagnosticLevel
.
debug
));
// COLORS
properties
.
add
(
DiagnosticsProperty
<
ColorScheme
>(
'colorScheme'
,
colorScheme
,
defaultValue:
defaultData
.
colorScheme
,
level:
DiagnosticLevel
.
debug
));
properties
.
add
(
ColorProperty
(
'primaryColor'
,
primaryColor
,
defaultValue:
defaultData
.
primaryColor
,
level:
DiagnosticLevel
.
debug
));
...
...
packages/flutter/test/material/theme_data_test.dart
View file @
7d098177
...
...
@@ -298,6 +298,7 @@ void main() {
highlightColor:
Colors
.
black
,
splashColor:
Colors
.
black
,
splashFactory:
InkRipple
.
splashFactory
,
useMaterial3:
false
,
selectedRowColor:
Colors
.
black
,
unselectedWidgetColor:
Colors
.
black
,
disabledColor:
Colors
.
black
,
...
...
@@ -396,6 +397,7 @@ void main() {
highlightColor:
Colors
.
white
,
splashColor:
Colors
.
white
,
splashFactory:
InkRipple
.
splashFactory
,
useMaterial3:
true
,
selectedRowColor:
Colors
.
white
,
unselectedWidgetColor:
Colors
.
white
,
disabledColor:
Colors
.
white
,
...
...
@@ -478,6 +480,7 @@ void main() {
highlightColor:
otherTheme
.
highlightColor
,
splashColor:
otherTheme
.
splashColor
,
splashFactory:
otherTheme
.
splashFactory
,
useMaterial3:
otherTheme
.
useMaterial3
,
selectedRowColor:
otherTheme
.
selectedRowColor
,
unselectedWidgetColor:
otherTheme
.
unselectedWidgetColor
,
disabledColor:
otherTheme
.
disabledColor
,
...
...
@@ -556,6 +559,7 @@ void main() {
expect
(
themeDataCopy
.
highlightColor
,
equals
(
otherTheme
.
highlightColor
));
expect
(
themeDataCopy
.
splashColor
,
equals
(
otherTheme
.
splashColor
));
expect
(
themeDataCopy
.
splashFactory
,
equals
(
otherTheme
.
splashFactory
));
expect
(
themeDataCopy
.
useMaterial3
,
equals
(
otherTheme
.
useMaterial3
));
expect
(
themeDataCopy
.
selectedRowColor
,
equals
(
otherTheme
.
selectedRowColor
));
expect
(
themeDataCopy
.
unselectedWidgetColor
,
equals
(
otherTheme
.
unselectedWidgetColor
));
expect
(
themeDataCopy
.
disabledColor
,
equals
(
otherTheme
.
disabledColor
));
...
...
@@ -667,6 +671,7 @@ void main() {
'scrollbarTheme'
,
'splashFactory'
,
'visualDensity'
,
'useMaterial3'
,
// COLOR
'colorScheme'
,
'primaryColor'
,
...
...
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