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
32981c4c
Unverified
Commit
32981c4c
authored
Jun 14, 2022
by
Darren Austin
Committed by
GitHub
Jun 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added useMaterial3 parameters to the light, dark and fallback ThemeData constructors. (#105944)
parent
f1c637e7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
theme_data.dart
packages/flutter/lib/src/material/theme_data.dart
+9
-3
theme_data_test.dart
packages/flutter/test/material/theme_data_test.dart
+14
-0
No files found.
packages/flutter/lib/src/material/theme_data.dart
View file @
32981c4c
...
...
@@ -961,13 +961,19 @@ class ThemeData with Diagnosticable {
///
/// This theme does not contain text geometry. Instead, it is expected that
/// this theme is localized using text geometry using [ThemeData.localize].
factory
ThemeData
.
light
()
=>
ThemeData
(
brightness:
Brightness
.
light
);
factory
ThemeData
.
light
({
bool
?
useMaterial3
})
=>
ThemeData
(
brightness:
Brightness
.
light
,
useMaterial3:
useMaterial3
,
);
/// A default dark theme with a teal secondary [ColorScheme] color.
///
/// This theme does not contain text geometry. Instead, it is expected that
/// this theme is localized using text geometry using [ThemeData.localize].
factory
ThemeData
.
dark
()
=>
ThemeData
(
brightness:
Brightness
.
dark
);
factory
ThemeData
.
dark
({
bool
?
useMaterial3
})
=>
ThemeData
(
brightness:
Brightness
.
dark
,
useMaterial3:
useMaterial3
,
);
/// The default color theme. Same as [ThemeData.light].
///
...
...
@@ -978,7 +984,7 @@ class ThemeData with Diagnosticable {
///
/// Most applications would use [Theme.of], which provides correct localized
/// text geometry.
factory
ThemeData
.
fallback
(
)
=>
ThemeData
.
light
(
);
factory
ThemeData
.
fallback
(
{
bool
?
useMaterial3
})
=>
ThemeData
.
light
(
useMaterial3:
useMaterial3
);
/// The overall theme brightness.
///
...
...
packages/flutter/test/material/theme_data_test.dart
View file @
32981c4c
...
...
@@ -125,6 +125,20 @@ void main() {
expect
(
darkTheme
.
primaryTextTheme
.
headline6
!.
color
,
typography
.
white
.
headline6
!.
color
);
});
test
(
'light, dark and fallback constructors support useMaterial3'
,
()
{
final
ThemeData
lightTheme
=
ThemeData
.
light
(
useMaterial3:
true
);
expect
(
lightTheme
.
useMaterial3
,
true
);
expect
(
lightTheme
.
typography
,
Typography
.
material2021
());
final
ThemeData
darkTheme
=
ThemeData
.
dark
(
useMaterial3:
true
);
expect
(
darkTheme
.
useMaterial3
,
true
);
expect
(
darkTheme
.
typography
,
Typography
.
material2021
());
final
ThemeData
fallbackTheme
=
ThemeData
.
light
(
useMaterial3:
true
);
expect
(
fallbackTheme
.
useMaterial3
,
true
);
expect
(
fallbackTheme
.
typography
,
Typography
.
material2021
());
});
testWidgets
(
'Defaults to MaterialTapTargetBehavior.padded on mobile platforms and MaterialTapTargetBehavior.shrinkWrap on desktop'
,
(
WidgetTester
tester
)
async
{
final
ThemeData
themeData
=
ThemeData
(
platform:
defaultTargetPlatform
);
switch
(
defaultTargetPlatform
)
{
...
...
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