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
8661dc40
Unverified
Commit
8661dc40
authored
Sep 06, 2019
by
LongCatIsLooong
Committed by
GitHub
Sep 06, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make CupertinoDynamicColor.resolve return null when given a null color (#39927)
parent
57d714eb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
6 deletions
+10
-6
colors.dart
packages/flutter/lib/src/cupertino/colors.dart
+3
-1
text_theme.dart
packages/flutter/lib/src/cupertino/text_theme.dart
+1
-1
theme.dart
packages/flutter/lib/src/cupertino/theme.dart
+2
-4
colors_test.dart
packages/flutter/test/cupertino/colors_test.dart
+4
-0
No files found.
packages/flutter/lib/src/cupertino/colors.dart
View file @
8661dc40
...
...
@@ -325,13 +325,15 @@ class CupertinoDynamicColor extends Color {
/// Resolves the given [Color] by calling [resolveFrom].
///
/// If the given color is already a concrete [Color], it will be returned as is.
/// If the given color is null, returns null.
/// If the given color is a [CupertinoDynamicColor], but the given [BuildContext]
/// lacks the dependencies required to the color resolution, the default trait
/// value will be used ([Brightness.light] platform brightness, normal contrast,
/// [CupertinoUserInterfaceLevelData.base] elevation level), unless [nullOk] is
/// set to false, in which case an exception will be thrown.
static
Color
resolve
(
Color
resolvable
,
BuildContext
context
,
{
bool
nullOk
=
true
})
{
assert
(
resolvable
!=
null
);
if
(
resolvable
==
null
)
return
null
;
assert
(
context
!=
null
);
return
(
resolvable
is
CupertinoDynamicColor
)
?
resolvable
.
resolveFrom
(
context
,
nullOk:
nullOk
)
...
...
packages/flutter/lib/src/cupertino/text_theme.dart
View file @
8661dc40
...
...
@@ -216,7 +216,7 @@ class CupertinoTextThemeData extends Diagnosticable {
/// Returns a copy of the current [CupertinoTextThemeData] with all the colors
/// resolved against the given [BuildContext].
CupertinoTextThemeData
resolveFrom
(
BuildContext
context
,
{
bool
nullOk
=
false
})
{
Color
convertColor
(
Color
color
)
=>
color
==
null
?
null
:
CupertinoDynamicColor
.
resolve
(
color
,
context
,
nullOk:
nullOk
);
Color
convertColor
(
Color
color
)
=>
CupertinoDynamicColor
.
resolve
(
color
,
context
,
nullOk:
nullOk
);
TextStyle
resolveTextStyle
(
TextStyle
textStyle
)
{
return
textStyle
?.
copyWith
(
...
...
packages/flutter/lib/src/cupertino/theme.dart
View file @
8661dc40
...
...
@@ -248,7 +248,7 @@ class CupertinoThemeData extends Diagnosticable {
/// It will be called in [CupertinoTheme.of].
@protected
CupertinoThemeData
resolveFrom
(
BuildContext
context
,
{
bool
nullOk
=
false
})
{
Color
convertColor
(
Color
color
)
=>
color
==
null
?
null
:
CupertinoDynamicColor
.
resolve
(
color
,
context
,
nullOk:
nullOk
);
Color
convertColor
(
Color
color
)
=>
CupertinoDynamicColor
.
resolve
(
color
,
context
,
nullOk:
nullOk
);
return
copyWith
(
primaryColor:
convertColor
(
primaryColor
),
...
...
@@ -329,9 +329,7 @@ class _NoDefaultCupertinoThemeData extends CupertinoThemeData {
@override
_NoDefaultCupertinoThemeData
resolveFrom
(
BuildContext
context
,
{
bool
nullOk
=
false
})
{
Color
convertColor
(
Color
color
)
=>
color
==
null
?
null
:
CupertinoDynamicColor
.
resolve
(
color
,
context
,
nullOk:
nullOk
);
Color
convertColor
(
Color
color
)
=>
CupertinoDynamicColor
.
resolve
(
color
,
context
,
nullOk:
nullOk
);
return
_NoDefaultCupertinoThemeData
(
brightness
,
...
...
packages/flutter/test/cupertino/colors_test.dart
View file @
8661dc40
...
...
@@ -160,6 +160,10 @@ void main() {
);
});
test
(
'can resolve null color'
,
()
{
expect
(
CupertinoDynamicColor
.
resolve
(
null
,
null
),
isNull
);
});
test
(
'withVibrancy constructor creates colors that may depend on vibrancy'
,
()
{
expect
(
vibrancyDependentColor1
,
const
CupertinoDynamicColor
.
withBrightness
(
color:
color1
,
...
...
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