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
643da4b7
Unverified
Commit
643da4b7
authored
Aug 04, 2020
by
Rami
Committed by
GitHub
Aug 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure dark theme is used when high contrast dark theme isn't provided (#62668)
parent
c90c4b35
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
3 deletions
+31
-3
app.dart
packages/flutter/lib/src/material/app.dart
+3
-3
app_test.dart
packages/flutter/test/material/app_test.dart
+28
-0
No files found.
packages/flutter/lib/src/material/app.dart
View file @
643da4b7
...
...
@@ -655,11 +655,11 @@ class _MaterialAppState extends State<MaterialApp> {
final
bool
highContrast
=
MediaQuery
.
highContrastOf
(
context
);
ThemeData
theme
;
if
(
useDarkTheme
&&
highContrast
)
{
if
(
useDarkTheme
&&
highContrast
&&
widget
.
highContrastDarkTheme
!=
null
)
{
theme
=
widget
.
highContrastDarkTheme
;
}
else
if
(
useDarkTheme
)
{
}
else
if
(
useDarkTheme
&&
widget
.
darkTheme
!=
null
)
{
theme
=
widget
.
darkTheme
;
}
else
if
(
highContrast
)
{
}
else
if
(
highContrast
&&
widget
.
highContrastTheme
!=
null
)
{
theme
=
widget
.
highContrastTheme
;
}
theme
??=
widget
.
theme
??
ThemeData
.
light
();
...
...
packages/flutter/test/material/app_test.dart
View file @
643da4b7
...
...
@@ -812,6 +812,34 @@ void main() {
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
null
;
});
testWidgets
(
'MaterialApp uses dark theme when no high contrast dark theme is provided'
,
(
WidgetTester
tester
)
async
{
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
MockAccessibilityFeature
();
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
primaryColor:
Colors
.
lightBlue
,
),
darkTheme:
ThemeData
(
primaryColor:
Colors
.
lightGreen
,
),
home:
Builder
(
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
return
const
SizedBox
();
},
),
),
);
expect
(
appliedTheme
.
primaryColor
,
Colors
.
lightGreen
);
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
null
;
tester
.
binding
.
window
.
platformBrightnessTestValue
=
null
;
});
testWidgets
(
'MaterialApp switches themes when the Window platformBrightness changes.'
,
(
WidgetTester
tester
)
async
{
// Mock the Window to explicitly report a light platformBrightness.
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
...
...
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