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
69788322
Unverified
Commit
69788322
authored
Sep 16, 2020
by
Alexandre Ardhuin
Committed by
GitHub
Sep 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate some cupertino files to nullsafety (#65880)
parent
10a66b19
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
163 additions
and
156 deletions
+163
-156
colors.dart
packages/flutter/lib/src/cupertino/colors.dart
+27
-29
icon_theme_data.dart
packages/flutter/lib/src/cupertino/icon_theme_data.dart
+5
-7
interface_level.dart
packages/flutter/lib/src/cupertino/interface_level.dart
+5
-7
text_theme.dart
packages/flutter/lib/src/cupertino/text_theme.dart
+39
-41
theme.dart
packages/flutter/lib/src/cupertino/theme.dart
+69
-71
colors_test.dart
packages/flutter/test/cupertino/colors_test.dart
+18
-1
No files found.
packages/flutter/lib/src/cupertino/colors.dart
View file @
69788322
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:ui'
show
Color
,
Brightness
;
import
'../../foundation.dart'
;
...
...
@@ -683,15 +681,15 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
///
/// All the colors must not be null.
const
CupertinoDynamicColor
({
String
debugLabel
,
@
required
Color
color
,
@
required
Color
darkColor
,
@
required
Color
highContrastColor
,
@
required
Color
darkHighContrastColor
,
@
required
Color
elevatedColor
,
@
required
Color
darkElevatedColor
,
@
required
Color
highContrastElevatedColor
,
@
required
Color
darkHighContrastElevatedColor
,
String
?
debugLabel
,
required
Color
color
,
required
Color
darkColor
,
required
Color
highContrastColor
,
required
Color
darkHighContrastColor
,
required
Color
elevatedColor
,
required
Color
darkElevatedColor
,
required
Color
highContrastElevatedColor
,
required
Color
darkHighContrastElevatedColor
,
})
:
this
.
_
(
color
,
color
,
...
...
@@ -713,11 +711,11 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
///
/// All the colors must not be null.
const
CupertinoDynamicColor
.
withBrightnessAndContrast
({
String
debugLabel
,
@
required
Color
color
,
@
required
Color
darkColor
,
@
required
Color
highContrastColor
,
@
required
Color
darkHighContrastColor
,
String
?
debugLabel
,
required
Color
color
,
required
Color
darkColor
,
required
Color
highContrastColor
,
required
Color
darkHighContrastColor
,
})
:
this
(
debugLabel:
debugLabel
,
color:
color
,
...
...
@@ -736,9 +734,9 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
///
/// All the colors must not be null.
const
CupertinoDynamicColor
.
withBrightness
({
String
debugLabel
,
@
required
Color
color
,
@
required
Color
darkColor
,
String
?
debugLabel
,
required
Color
color
,
required
Color
darkColor
,
})
:
this
(
debugLabel:
debugLabel
,
color:
color
,
...
...
@@ -786,9 +784,9 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
@override
int
get
value
=>
_effectiveColor
.
value
;
final
String
_debugLabel
;
final
String
?
_debugLabel
;
final
Element
_debugResolveContext
;
final
Element
?
_debugResolveContext
;
/// The color to use when the [BuildContext] implies a combination of light mode,
/// normal contrast, and base interface elevation.
...
...
@@ -887,7 +885,7 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
/// 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
})
{
static
Color
?
resolve
(
Color
?
resolvable
,
BuildContext
context
,
{
bool
nullOk
=
true
})
{
if
(
resolvable
==
null
)
return
null
;
assert
(
context
!=
null
);
...
...
@@ -981,7 +979,7 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
}
}
Element
_debugContext
;
Element
?
_debugContext
;
assert
(()
{
_debugContext
=
context
as
Element
;
return
true
;
...
...
@@ -1058,7 +1056,7 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
super
.
debugFillProperties
(
properties
);
if
(
_debugLabel
!=
null
)
properties
.
add
(
MessageProperty
(
'debugLabel'
,
_debugLabel
));
properties
.
add
(
MessageProperty
(
'debugLabel'
,
_debugLabel
!
));
properties
.
add
(
createCupertinoColorProperty
(
'color'
,
color
));
if
(
_isPlatformBrightnessDependent
)
properties
.
add
(
createCupertinoColorProperty
(
'darkColor'
,
darkColor
));
...
...
@@ -1085,11 +1083,11 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
/// The [showName], [style], and [level] arguments must not be null.
DiagnosticsProperty
<
Color
>
createCupertinoColorProperty
(
String
name
,
Color
value
,
{
bool
showName
=
true
,
Object
defaultValue
=
kNoDefaultValue
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
Color
?
value
,
{
bool
showName
=
true
,
Object
?
defaultValue
=
kNoDefaultValue
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
})
{
if
(
value
is
CupertinoDynamicColor
)
{
return
DiagnosticsProperty
<
CupertinoDynamicColor
>(
...
...
packages/flutter/lib/src/cupertino/icon_theme_data.dart
View file @
69788322
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'colors.dart'
;
...
...
@@ -16,22 +14,22 @@ class CupertinoIconThemeData extends IconThemeData with Diagnosticable {
/// The opacity applies to both explicit and default icon colors. The value
/// is clamped between 0.0 and 1.0.
const
CupertinoIconThemeData
({
Color
color
,
double
opacity
,
double
size
Color
?
color
,
double
?
opacity
,
double
?
size
,
})
:
super
(
color:
color
,
opacity:
opacity
,
size:
size
);
/// Called by [IconTheme.of] to resolve [color] against the given [BuildContext].
@override
IconThemeData
resolve
(
BuildContext
context
)
{
final
Color
resolvedColor
=
CupertinoDynamicColor
.
resolve
(
color
,
context
);
final
Color
?
resolvedColor
=
CupertinoDynamicColor
.
resolve
(
color
,
context
);
return
resolvedColor
==
color
?
this
:
copyWith
(
color:
resolvedColor
);
}
/// Creates a copy of this icon theme but with the given fields replaced with
/// the new values.
@override
CupertinoIconThemeData
copyWith
({
Color
color
,
double
opacity
,
double
size
})
{
CupertinoIconThemeData
copyWith
({
Color
?
color
,
double
?
opacity
,
double
?
size
})
{
return
CupertinoIconThemeData
(
color:
color
??
this
.
color
,
opacity:
opacity
??
this
.
opacity
,
...
...
packages/flutter/lib/src/cupertino/interface_level.dart
View file @
69788322
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'../widgets/framework.dart'
;
...
...
@@ -41,9 +39,9 @@ class CupertinoUserInterfaceLevel extends InheritedWidget {
/// Creates a [CupertinoUserInterfaceLevel] to change descendant Cupertino widget's
/// visual level.
const
CupertinoUserInterfaceLevel
({
Key
key
,
@
required
CupertinoUserInterfaceLevelData
data
,
Widget
child
,
Key
?
key
,
required
CupertinoUserInterfaceLevelData
data
,
required
Widget
child
,
})
:
assert
(
data
!=
null
),
_data
=
data
,
super
(
key:
key
,
child:
child
);
...
...
@@ -59,10 +57,10 @@ class CupertinoUserInterfaceLevel extends InheritedWidget {
/// You can use this function to query the user interface elevation level within
/// the given [BuildContext]. When that information changes, your widget will
/// be scheduled to be rebuilt, keeping your widget up-to-date.
static
CupertinoUserInterfaceLevelData
of
(
BuildContext
context
,
{
bool
nullOk
=
false
})
{
static
CupertinoUserInterfaceLevelData
?
of
(
BuildContext
context
,
{
bool
nullOk
=
false
})
{
assert
(
context
!=
null
);
assert
(
nullOk
!=
null
);
final
CupertinoUserInterfaceLevel
query
=
context
.
dependOnInheritedWidgetOfExactType
<
CupertinoUserInterfaceLevel
>();
final
CupertinoUserInterfaceLevel
?
query
=
context
.
dependOnInheritedWidgetOfExactType
<
CupertinoUserInterfaceLevel
>();
if
(
query
!=
null
)
return
query
.
_data
;
if
(
nullOk
)
...
...
packages/flutter/lib/src/cupertino/text_theme.dart
View file @
69788322
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/services.dart'
show
Brightness
;
import
'package:flutter/widgets.dart'
;
...
...
@@ -98,12 +96,12 @@ const TextStyle _kDefaultDateTimePickerTextStyle = TextStyle(
color:
CupertinoColors
.
label
,
);
TextStyle
_resolveTextStyle
(
TextStyle
style
,
BuildContext
context
,
bool
nullOk
)
{
TextStyle
?
_resolveTextStyle
(
TextStyle
?
style
,
BuildContext
context
,
bool
nullOk
)
{
// This does not resolve the shadow color, foreground, background, etc.
return
style
?.
copyWith
(
color:
CupertinoDynamicColor
.
resolve
(
style
?
.
color
,
context
,
nullOk:
nullOk
),
backgroundColor:
CupertinoDynamicColor
.
resolve
(
style
?
.
backgroundColor
,
context
,
nullOk:
nullOk
),
decorationColor:
CupertinoDynamicColor
.
resolve
(
style
?
.
decorationColor
,
context
,
nullOk:
nullOk
),
color:
CupertinoDynamicColor
.
resolve
(
style
.
color
,
context
,
nullOk:
nullOk
),
backgroundColor:
CupertinoDynamicColor
.
resolve
(
style
.
backgroundColor
,
context
,
nullOk:
nullOk
),
decorationColor:
CupertinoDynamicColor
.
resolve
(
style
.
decorationColor
,
context
,
nullOk:
nullOk
),
);
}
...
...
@@ -126,15 +124,15 @@ class CupertinoTextThemeData with Diagnosticable {
'This argument no longer does anything. You can remove it. '
'This feature was deprecated after v1.10.14.'
)
Brightness
brightness
,
TextStyle
textStyle
,
TextStyle
actionTextStyle
,
TextStyle
tabLabelTextStyle
,
TextStyle
navTitleTextStyle
,
TextStyle
navLargeTitleTextStyle
,
TextStyle
navActionTextStyle
,
TextStyle
pickerTextStyle
,
TextStyle
dateTimePickerTextStyle
,
Brightness
?
brightness
,
TextStyle
?
textStyle
,
TextStyle
?
actionTextStyle
,
TextStyle
?
tabLabelTextStyle
,
TextStyle
?
navTitleTextStyle
,
TextStyle
?
navLargeTitleTextStyle
,
TextStyle
?
navActionTextStyle
,
TextStyle
?
pickerTextStyle
,
TextStyle
?
dateTimePickerTextStyle
,
})
:
this
.
_raw
(
const
_TextThemeDefaultsBuilder
(
CupertinoColors
.
label
,
CupertinoColors
.
inactiveGray
),
primaryColor
,
...
...
@@ -162,41 +160,41 @@ class CupertinoTextThemeData with Diagnosticable {
)
:
assert
((
_navActionTextStyle
!=
null
&&
_actionTextStyle
!=
null
)
||
_primaryColor
!=
null
);
final
_TextThemeDefaultsBuilder
_defaults
;
final
Color
_primaryColor
;
final
Color
?
_primaryColor
;
final
TextStyle
_textStyle
;
final
TextStyle
?
_textStyle
;
/// The [TextStyle] of general text content for Cupertino widgets.
TextStyle
get
textStyle
=>
_textStyle
??
_defaults
.
textStyle
;
final
TextStyle
_actionTextStyle
;
final
TextStyle
?
_actionTextStyle
;
/// The [TextStyle] of interactive text content such as text in a button without background.
TextStyle
get
actionTextStyle
{
return
_actionTextStyle
??
_defaults
.
actionTextStyle
(
primaryColor:
_primaryColor
);
}
final
TextStyle
_tabLabelTextStyle
;
final
TextStyle
?
_tabLabelTextStyle
;
/// The [TextStyle] of unselected tabs.
TextStyle
get
tabLabelTextStyle
=>
_tabLabelTextStyle
??
_defaults
.
tabLabelTextStyle
;
final
TextStyle
_navTitleTextStyle
;
final
TextStyle
?
_navTitleTextStyle
;
/// The [TextStyle] of titles in standard navigation bars.
TextStyle
get
navTitleTextStyle
=>
_navTitleTextStyle
??
_defaults
.
navTitleTextStyle
;
final
TextStyle
_navLargeTitleTextStyle
;
final
TextStyle
?
_navLargeTitleTextStyle
;
/// The [TextStyle] of large titles in sliver navigation bars.
TextStyle
get
navLargeTitleTextStyle
=>
_navLargeTitleTextStyle
??
_defaults
.
navLargeTitleTextStyle
;
final
TextStyle
_navActionTextStyle
;
final
TextStyle
?
_navActionTextStyle
;
/// The [TextStyle] of interactive text content in navigation bars.
TextStyle
get
navActionTextStyle
{
return
_navActionTextStyle
??
_defaults
.
navActionTextStyle
(
primaryColor:
_primaryColor
);
}
final
TextStyle
_pickerTextStyle
;
final
TextStyle
?
_pickerTextStyle
;
/// The [TextStyle] of pickers.
TextStyle
get
pickerTextStyle
=>
_pickerTextStyle
??
_defaults
.
pickerTextStyle
;
final
TextStyle
_dateTimePickerTextStyle
;
final
TextStyle
?
_dateTimePickerTextStyle
;
/// The [TextStyle] of date time pickers.
TextStyle
get
dateTimePickerTextStyle
=>
_dateTimePickerTextStyle
??
_defaults
.
dateTimePickerTextStyle
;
...
...
@@ -209,7 +207,7 @@ class CupertinoTextThemeData with Diagnosticable {
/// be used as-is.
CupertinoTextThemeData
resolveFrom
(
BuildContext
context
,
{
bool
nullOk
=
false
})
{
return
CupertinoTextThemeData
.
_raw
(
_defaults
?
.
resolveFrom
(
context
,
nullOk
),
_defaults
.
resolveFrom
(
context
,
nullOk
),
CupertinoDynamicColor
.
resolve
(
_primaryColor
,
context
,
nullOk:
nullOk
),
_resolveTextStyle
(
_textStyle
,
context
,
nullOk
),
_resolveTextStyle
(
_actionTextStyle
,
context
,
nullOk
),
...
...
@@ -225,20 +223,20 @@ class CupertinoTextThemeData with Diagnosticable {
/// Returns a copy of the current [CupertinoTextThemeData] instance with
/// specified overrides.
CupertinoTextThemeData
copyWith
({
Color
primaryColor
,
Color
?
primaryColor
,
@Deprecated
(
'This argument no longer does anything. You can remove it. '
'This feature was deprecated after v1.10.14.'
)
Brightness
brightness
,
TextStyle
textStyle
,
TextStyle
actionTextStyle
,
TextStyle
tabLabelTextStyle
,
TextStyle
navTitleTextStyle
,
TextStyle
navLargeTitleTextStyle
,
TextStyle
navActionTextStyle
,
TextStyle
pickerTextStyle
,
TextStyle
dateTimePickerTextStyle
,
Brightness
?
brightness
,
TextStyle
?
textStyle
,
TextStyle
?
actionTextStyle
,
TextStyle
?
tabLabelTextStyle
,
TextStyle
?
navTitleTextStyle
,
TextStyle
?
navLargeTitleTextStyle
,
TextStyle
?
navActionTextStyle
,
TextStyle
?
pickerTextStyle
,
TextStyle
?
dateTimePickerTextStyle
,
})
{
return
CupertinoTextThemeData
.
_raw
(
_defaults
,
...
...
@@ -282,9 +280,9 @@ class _TextThemeDefaultsBuilder {
final
Color
inactiveGrayColor
;
static
TextStyle
_applyLabelColor
(
TextStyle
original
,
Color
color
)
{
return
original
?
.
color
==
color
return
original
.
color
==
color
?
original
:
original
?
.
copyWith
(
color:
color
);
:
original
.
copyWith
(
color:
color
);
}
TextStyle
get
textStyle
=>
_applyLabelColor
(
_kDefaultTextStyle
,
labelColor
);
...
...
@@ -294,12 +292,12 @@ class _TextThemeDefaultsBuilder {
TextStyle
get
pickerTextStyle
=>
_applyLabelColor
(
_kDefaultPickerTextStyle
,
labelColor
);
TextStyle
get
dateTimePickerTextStyle
=>
_applyLabelColor
(
_kDefaultDateTimePickerTextStyle
,
labelColor
);
TextStyle
actionTextStyle
({
Color
primaryColor
})
=>
_kDefaultActionTextStyle
.
copyWith
(
color:
primaryColor
);
TextStyle
navActionTextStyle
({
Color
primaryColor
})
=>
actionTextStyle
(
primaryColor:
primaryColor
);
TextStyle
actionTextStyle
({
Color
?
primaryColor
})
=>
_kDefaultActionTextStyle
.
copyWith
(
color:
primaryColor
);
TextStyle
navActionTextStyle
({
Color
?
primaryColor
})
=>
actionTextStyle
(
primaryColor:
primaryColor
);
_TextThemeDefaultsBuilder
resolveFrom
(
BuildContext
context
,
bool
nullOk
)
{
final
Color
resolvedLabelColor
=
CupertinoDynamicColor
.
resolve
(
labelColor
,
context
,
nullOk:
nullOk
);
final
Color
resolvedInactiveGray
=
CupertinoDynamicColor
.
resolve
(
inactiveGrayColor
,
context
,
nullOk:
nullOk
);
final
Color
resolvedLabelColor
=
CupertinoDynamicColor
.
resolve
(
labelColor
,
context
,
nullOk:
nullOk
)
!
;
final
Color
resolvedInactiveGray
=
CupertinoDynamicColor
.
resolve
(
inactiveGrayColor
,
context
,
nullOk:
nullOk
)
!
;
return
resolvedLabelColor
==
labelColor
&&
resolvedInactiveGray
==
CupertinoColors
.
inactiveGray
?
this
:
_TextThemeDefaultsBuilder
(
resolvedLabelColor
,
resolvedInactiveGray
);
...
...
packages/flutter/lib/src/cupertino/theme.dart
View file @
69788322
This diff is collapsed.
Click to expand it.
packages/flutter/test/cupertino/colors_test.dart
View file @
69788322
...
...
@@ -167,7 +167,7 @@ void main() {
});
test
(
'can resolve null color'
,
()
{
expect
(
CupertinoDynamicColor
.
resolve
(
null
,
null
),
isNull
);
expect
(
CupertinoDynamicColor
.
resolve
(
null
,
_NullElement
.
instance
),
isNull
);
});
test
(
'withVibrancy constructor creates colors that may depend on vibrancy'
,
()
{
...
...
@@ -589,3 +589,20 @@ void main() {
});
});
}
class
_NullElement
extends
Element
{
_NullElement
()
:
super
(
_NullWidget
());
static
_NullElement
instance
=
_NullElement
();
@override
bool
get
debugDoingBuild
=>
throw
UnimplementedError
();
@override
void
performRebuild
()
{
}
}
class
_NullWidget
extends
Widget
{
@override
Element
createElement
()
=>
throw
UnimplementedError
();
}
\ No newline at end of file
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