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
Show 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 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:ui'
show
Color
,
Brightness
;
import
'dart:ui'
show
Color
,
Brightness
;
import
'../../foundation.dart'
;
import
'../../foundation.dart'
;
...
@@ -683,15 +681,15 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
...
@@ -683,15 +681,15 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
///
///
/// All the colors must not be null.
/// All the colors must not be null.
const
CupertinoDynamicColor
({
const
CupertinoDynamicColor
({
String
debugLabel
,
String
?
debugLabel
,
@
required
Color
color
,
required
Color
color
,
@
required
Color
darkColor
,
required
Color
darkColor
,
@
required
Color
highContrastColor
,
required
Color
highContrastColor
,
@
required
Color
darkHighContrastColor
,
required
Color
darkHighContrastColor
,
@
required
Color
elevatedColor
,
required
Color
elevatedColor
,
@
required
Color
darkElevatedColor
,
required
Color
darkElevatedColor
,
@
required
Color
highContrastElevatedColor
,
required
Color
highContrastElevatedColor
,
@
required
Color
darkHighContrastElevatedColor
,
required
Color
darkHighContrastElevatedColor
,
})
:
this
.
_
(
})
:
this
.
_
(
color
,
color
,
color
,
color
,
...
@@ -713,11 +711,11 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
...
@@ -713,11 +711,11 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
///
///
/// All the colors must not be null.
/// All the colors must not be null.
const
CupertinoDynamicColor
.
withBrightnessAndContrast
({
const
CupertinoDynamicColor
.
withBrightnessAndContrast
({
String
debugLabel
,
String
?
debugLabel
,
@
required
Color
color
,
required
Color
color
,
@
required
Color
darkColor
,
required
Color
darkColor
,
@
required
Color
highContrastColor
,
required
Color
highContrastColor
,
@
required
Color
darkHighContrastColor
,
required
Color
darkHighContrastColor
,
})
:
this
(
})
:
this
(
debugLabel:
debugLabel
,
debugLabel:
debugLabel
,
color:
color
,
color:
color
,
...
@@ -736,9 +734,9 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
...
@@ -736,9 +734,9 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
///
///
/// All the colors must not be null.
/// All the colors must not be null.
const
CupertinoDynamicColor
.
withBrightness
({
const
CupertinoDynamicColor
.
withBrightness
({
String
debugLabel
,
String
?
debugLabel
,
@
required
Color
color
,
required
Color
color
,
@
required
Color
darkColor
,
required
Color
darkColor
,
})
:
this
(
})
:
this
(
debugLabel:
debugLabel
,
debugLabel:
debugLabel
,
color:
color
,
color:
color
,
...
@@ -786,9 +784,9 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
...
@@ -786,9 +784,9 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
@override
@override
int
get
value
=>
_effectiveColor
.
value
;
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,
/// The color to use when the [BuildContext] implies a combination of light mode,
/// normal contrast, and base interface elevation.
/// normal contrast, and base interface elevation.
...
@@ -887,7 +885,7 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
...
@@ -887,7 +885,7 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
/// value will be used ([Brightness.light] platform brightness, normal contrast,
/// value will be used ([Brightness.light] platform brightness, normal contrast,
/// [CupertinoUserInterfaceLevelData.base] elevation level), unless [nullOk] is
/// [CupertinoUserInterfaceLevelData.base] elevation level), unless [nullOk] is
/// set to false, in which case an exception will be thrown.
/// 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
)
if
(
resolvable
==
null
)
return
null
;
return
null
;
assert
(
context
!=
null
);
assert
(
context
!=
null
);
...
@@ -981,7 +979,7 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
...
@@ -981,7 +979,7 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
}
}
}
}
Element
_debugContext
;
Element
?
_debugContext
;
assert
(()
{
assert
(()
{
_debugContext
=
context
as
Element
;
_debugContext
=
context
as
Element
;
return
true
;
return
true
;
...
@@ -1058,7 +1056,7 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
...
@@ -1058,7 +1056,7 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
super
.
debugFillProperties
(
properties
);
super
.
debugFillProperties
(
properties
);
if
(
_debugLabel
!=
null
)
if
(
_debugLabel
!=
null
)
properties
.
add
(
MessageProperty
(
'debugLabel'
,
_debugLabel
));
properties
.
add
(
MessageProperty
(
'debugLabel'
,
_debugLabel
!
));
properties
.
add
(
createCupertinoColorProperty
(
'color'
,
color
));
properties
.
add
(
createCupertinoColorProperty
(
'color'
,
color
));
if
(
_isPlatformBrightnessDependent
)
if
(
_isPlatformBrightnessDependent
)
properties
.
add
(
createCupertinoColorProperty
(
'darkColor'
,
darkColor
));
properties
.
add
(
createCupertinoColorProperty
(
'darkColor'
,
darkColor
));
...
@@ -1085,9 +1083,9 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
...
@@ -1085,9 +1083,9 @@ class CupertinoDynamicColor extends Color with Diagnosticable {
/// The [showName], [style], and [level] arguments must not be null.
/// The [showName], [style], and [level] arguments must not be null.
DiagnosticsProperty
<
Color
>
createCupertinoColorProperty
(
DiagnosticsProperty
<
Color
>
createCupertinoColorProperty
(
String
name
,
String
name
,
Color
value
,
{
Color
?
value
,
{
bool
showName
=
true
,
bool
showName
=
true
,
Object
defaultValue
=
kNoDefaultValue
,
Object
?
defaultValue
=
kNoDefaultValue
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
})
{
})
{
...
...
packages/flutter/lib/src/cupertino/icon_theme_data.dart
View file @
69788322
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'colors.dart'
;
import
'colors.dart'
;
...
@@ -16,22 +14,22 @@ class CupertinoIconThemeData extends IconThemeData with Diagnosticable {
...
@@ -16,22 +14,22 @@ class CupertinoIconThemeData extends IconThemeData with Diagnosticable {
/// The opacity applies to both explicit and default icon colors. The value
/// The opacity applies to both explicit and default icon colors. The value
/// is clamped between 0.0 and 1.0.
/// is clamped between 0.0 and 1.0.
const
CupertinoIconThemeData
({
const
CupertinoIconThemeData
({
Color
color
,
Color
?
color
,
double
opacity
,
double
?
opacity
,
double
size
double
?
size
,
})
:
super
(
color:
color
,
opacity:
opacity
,
size:
size
);
})
:
super
(
color:
color
,
opacity:
opacity
,
size:
size
);
/// Called by [IconTheme.of] to resolve [color] against the given [BuildContext].
/// Called by [IconTheme.of] to resolve [color] against the given [BuildContext].
@override
@override
IconThemeData
resolve
(
BuildContext
context
)
{
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
);
return
resolvedColor
==
color
?
this
:
copyWith
(
color:
resolvedColor
);
}
}
/// Creates a copy of this icon theme but with the given fields replaced with
/// Creates a copy of this icon theme but with the given fields replaced with
/// the new values.
/// the new values.
@override
@override
CupertinoIconThemeData
copyWith
({
Color
color
,
double
opacity
,
double
size
})
{
CupertinoIconThemeData
copyWith
({
Color
?
color
,
double
?
opacity
,
double
?
size
})
{
return
CupertinoIconThemeData
(
return
CupertinoIconThemeData
(
color:
color
??
this
.
color
,
color:
color
??
this
.
color
,
opacity:
opacity
??
this
.
opacity
,
opacity:
opacity
??
this
.
opacity
,
...
...
packages/flutter/lib/src/cupertino/interface_level.dart
View file @
69788322
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'../widgets/framework.dart'
;
import
'../widgets/framework.dart'
;
...
@@ -41,9 +39,9 @@ class CupertinoUserInterfaceLevel extends InheritedWidget {
...
@@ -41,9 +39,9 @@ class CupertinoUserInterfaceLevel extends InheritedWidget {
/// Creates a [CupertinoUserInterfaceLevel] to change descendant Cupertino widget's
/// Creates a [CupertinoUserInterfaceLevel] to change descendant Cupertino widget's
/// visual level.
/// visual level.
const
CupertinoUserInterfaceLevel
({
const
CupertinoUserInterfaceLevel
({
Key
key
,
Key
?
key
,
@
required
CupertinoUserInterfaceLevelData
data
,
required
CupertinoUserInterfaceLevelData
data
,
Widget
child
,
required
Widget
child
,
})
:
assert
(
data
!=
null
),
})
:
assert
(
data
!=
null
),
_data
=
data
,
_data
=
data
,
super
(
key:
key
,
child:
child
);
super
(
key:
key
,
child:
child
);
...
@@ -59,10 +57,10 @@ class CupertinoUserInterfaceLevel extends InheritedWidget {
...
@@ -59,10 +57,10 @@ class CupertinoUserInterfaceLevel extends InheritedWidget {
/// You can use this function to query the user interface elevation level within
/// You can use this function to query the user interface elevation level within
/// the given [BuildContext]. When that information changes, your widget will
/// the given [BuildContext]. When that information changes, your widget will
/// be scheduled to be rebuilt, keeping your widget up-to-date.
/// 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
(
context
!=
null
);
assert
(
nullOk
!=
null
);
assert
(
nullOk
!=
null
);
final
CupertinoUserInterfaceLevel
query
=
context
.
dependOnInheritedWidgetOfExactType
<
CupertinoUserInterfaceLevel
>();
final
CupertinoUserInterfaceLevel
?
query
=
context
.
dependOnInheritedWidgetOfExactType
<
CupertinoUserInterfaceLevel
>();
if
(
query
!=
null
)
if
(
query
!=
null
)
return
query
.
_data
;
return
query
.
_data
;
if
(
nullOk
)
if
(
nullOk
)
...
...
packages/flutter/lib/src/cupertino/text_theme.dart
View file @
69788322
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/services.dart'
show
Brightness
;
import
'package:flutter/services.dart'
show
Brightness
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
@@ -98,12 +96,12 @@ const TextStyle _kDefaultDateTimePickerTextStyle = TextStyle(
...
@@ -98,12 +96,12 @@ const TextStyle _kDefaultDateTimePickerTextStyle = TextStyle(
color:
CupertinoColors
.
label
,
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.
// This does not resolve the shadow color, foreground, background, etc.
return
style
?.
copyWith
(
return
style
?.
copyWith
(
color:
CupertinoDynamicColor
.
resolve
(
style
?
.
color
,
context
,
nullOk:
nullOk
),
color:
CupertinoDynamicColor
.
resolve
(
style
.
color
,
context
,
nullOk:
nullOk
),
backgroundColor:
CupertinoDynamicColor
.
resolve
(
style
?
.
backgroundColor
,
context
,
nullOk:
nullOk
),
backgroundColor:
CupertinoDynamicColor
.
resolve
(
style
.
backgroundColor
,
context
,
nullOk:
nullOk
),
decorationColor:
CupertinoDynamicColor
.
resolve
(
style
?
.
decorationColor
,
context
,
nullOk:
nullOk
),
decorationColor:
CupertinoDynamicColor
.
resolve
(
style
.
decorationColor
,
context
,
nullOk:
nullOk
),
);
);
}
}
...
@@ -126,15 +124,15 @@ class CupertinoTextThemeData with Diagnosticable {
...
@@ -126,15 +124,15 @@ class CupertinoTextThemeData with Diagnosticable {
'This argument no longer does anything. You can remove it. '
'This argument no longer does anything. You can remove it. '
'This feature was deprecated after v1.10.14.'
'This feature was deprecated after v1.10.14.'
)
)
Brightness
brightness
,
Brightness
?
brightness
,
TextStyle
textStyle
,
TextStyle
?
textStyle
,
TextStyle
actionTextStyle
,
TextStyle
?
actionTextStyle
,
TextStyle
tabLabelTextStyle
,
TextStyle
?
tabLabelTextStyle
,
TextStyle
navTitleTextStyle
,
TextStyle
?
navTitleTextStyle
,
TextStyle
navLargeTitleTextStyle
,
TextStyle
?
navLargeTitleTextStyle
,
TextStyle
navActionTextStyle
,
TextStyle
?
navActionTextStyle
,
TextStyle
pickerTextStyle
,
TextStyle
?
pickerTextStyle
,
TextStyle
dateTimePickerTextStyle
,
TextStyle
?
dateTimePickerTextStyle
,
})
:
this
.
_raw
(
})
:
this
.
_raw
(
const
_TextThemeDefaultsBuilder
(
CupertinoColors
.
label
,
CupertinoColors
.
inactiveGray
),
const
_TextThemeDefaultsBuilder
(
CupertinoColors
.
label
,
CupertinoColors
.
inactiveGray
),
primaryColor
,
primaryColor
,
...
@@ -162,41 +160,41 @@ class CupertinoTextThemeData with Diagnosticable {
...
@@ -162,41 +160,41 @@ class CupertinoTextThemeData with Diagnosticable {
)
:
assert
((
_navActionTextStyle
!=
null
&&
_actionTextStyle
!=
null
)
||
_primaryColor
!=
null
);
)
:
assert
((
_navActionTextStyle
!=
null
&&
_actionTextStyle
!=
null
)
||
_primaryColor
!=
null
);
final
_TextThemeDefaultsBuilder
_defaults
;
final
_TextThemeDefaultsBuilder
_defaults
;
final
Color
_primaryColor
;
final
Color
?
_primaryColor
;
final
TextStyle
_textStyle
;
final
TextStyle
?
_textStyle
;
/// The [TextStyle] of general text content for Cupertino widgets.
/// The [TextStyle] of general text content for Cupertino widgets.
TextStyle
get
textStyle
=>
_textStyle
??
_defaults
.
textStyle
;
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.
/// The [TextStyle] of interactive text content such as text in a button without background.
TextStyle
get
actionTextStyle
{
TextStyle
get
actionTextStyle
{
return
_actionTextStyle
??
_defaults
.
actionTextStyle
(
primaryColor:
_primaryColor
);
return
_actionTextStyle
??
_defaults
.
actionTextStyle
(
primaryColor:
_primaryColor
);
}
}
final
TextStyle
_tabLabelTextStyle
;
final
TextStyle
?
_tabLabelTextStyle
;
/// The [TextStyle] of unselected tabs.
/// The [TextStyle] of unselected tabs.
TextStyle
get
tabLabelTextStyle
=>
_tabLabelTextStyle
??
_defaults
.
tabLabelTextStyle
;
TextStyle
get
tabLabelTextStyle
=>
_tabLabelTextStyle
??
_defaults
.
tabLabelTextStyle
;
final
TextStyle
_navTitleTextStyle
;
final
TextStyle
?
_navTitleTextStyle
;
/// The [TextStyle] of titles in standard navigation bars.
/// The [TextStyle] of titles in standard navigation bars.
TextStyle
get
navTitleTextStyle
=>
_navTitleTextStyle
??
_defaults
.
navTitleTextStyle
;
TextStyle
get
navTitleTextStyle
=>
_navTitleTextStyle
??
_defaults
.
navTitleTextStyle
;
final
TextStyle
_navLargeTitleTextStyle
;
final
TextStyle
?
_navLargeTitleTextStyle
;
/// The [TextStyle] of large titles in sliver navigation bars.
/// The [TextStyle] of large titles in sliver navigation bars.
TextStyle
get
navLargeTitleTextStyle
=>
_navLargeTitleTextStyle
??
_defaults
.
navLargeTitleTextStyle
;
TextStyle
get
navLargeTitleTextStyle
=>
_navLargeTitleTextStyle
??
_defaults
.
navLargeTitleTextStyle
;
final
TextStyle
_navActionTextStyle
;
final
TextStyle
?
_navActionTextStyle
;
/// The [TextStyle] of interactive text content in navigation bars.
/// The [TextStyle] of interactive text content in navigation bars.
TextStyle
get
navActionTextStyle
{
TextStyle
get
navActionTextStyle
{
return
_navActionTextStyle
??
_defaults
.
navActionTextStyle
(
primaryColor:
_primaryColor
);
return
_navActionTextStyle
??
_defaults
.
navActionTextStyle
(
primaryColor:
_primaryColor
);
}
}
final
TextStyle
_pickerTextStyle
;
final
TextStyle
?
_pickerTextStyle
;
/// The [TextStyle] of pickers.
/// The [TextStyle] of pickers.
TextStyle
get
pickerTextStyle
=>
_pickerTextStyle
??
_defaults
.
pickerTextStyle
;
TextStyle
get
pickerTextStyle
=>
_pickerTextStyle
??
_defaults
.
pickerTextStyle
;
final
TextStyle
_dateTimePickerTextStyle
;
final
TextStyle
?
_dateTimePickerTextStyle
;
/// The [TextStyle] of date time pickers.
/// The [TextStyle] of date time pickers.
TextStyle
get
dateTimePickerTextStyle
=>
_dateTimePickerTextStyle
??
_defaults
.
dateTimePickerTextStyle
;
TextStyle
get
dateTimePickerTextStyle
=>
_dateTimePickerTextStyle
??
_defaults
.
dateTimePickerTextStyle
;
...
@@ -209,7 +207,7 @@ class CupertinoTextThemeData with Diagnosticable {
...
@@ -209,7 +207,7 @@ class CupertinoTextThemeData with Diagnosticable {
/// be used as-is.
/// be used as-is.
CupertinoTextThemeData
resolveFrom
(
BuildContext
context
,
{
bool
nullOk
=
false
})
{
CupertinoTextThemeData
resolveFrom
(
BuildContext
context
,
{
bool
nullOk
=
false
})
{
return
CupertinoTextThemeData
.
_raw
(
return
CupertinoTextThemeData
.
_raw
(
_defaults
?
.
resolveFrom
(
context
,
nullOk
),
_defaults
.
resolveFrom
(
context
,
nullOk
),
CupertinoDynamicColor
.
resolve
(
_primaryColor
,
context
,
nullOk:
nullOk
),
CupertinoDynamicColor
.
resolve
(
_primaryColor
,
context
,
nullOk:
nullOk
),
_resolveTextStyle
(
_textStyle
,
context
,
nullOk
),
_resolveTextStyle
(
_textStyle
,
context
,
nullOk
),
_resolveTextStyle
(
_actionTextStyle
,
context
,
nullOk
),
_resolveTextStyle
(
_actionTextStyle
,
context
,
nullOk
),
...
@@ -225,20 +223,20 @@ class CupertinoTextThemeData with Diagnosticable {
...
@@ -225,20 +223,20 @@ class CupertinoTextThemeData with Diagnosticable {
/// Returns a copy of the current [CupertinoTextThemeData] instance with
/// Returns a copy of the current [CupertinoTextThemeData] instance with
/// specified overrides.
/// specified overrides.
CupertinoTextThemeData
copyWith
({
CupertinoTextThemeData
copyWith
({
Color
primaryColor
,
Color
?
primaryColor
,
@Deprecated
(
@Deprecated
(
'This argument no longer does anything. You can remove it. '
'This argument no longer does anything. You can remove it. '
'This feature was deprecated after v1.10.14.'
'This feature was deprecated after v1.10.14.'
)
)
Brightness
brightness
,
Brightness
?
brightness
,
TextStyle
textStyle
,
TextStyle
?
textStyle
,
TextStyle
actionTextStyle
,
TextStyle
?
actionTextStyle
,
TextStyle
tabLabelTextStyle
,
TextStyle
?
tabLabelTextStyle
,
TextStyle
navTitleTextStyle
,
TextStyle
?
navTitleTextStyle
,
TextStyle
navLargeTitleTextStyle
,
TextStyle
?
navLargeTitleTextStyle
,
TextStyle
navActionTextStyle
,
TextStyle
?
navActionTextStyle
,
TextStyle
pickerTextStyle
,
TextStyle
?
pickerTextStyle
,
TextStyle
dateTimePickerTextStyle
,
TextStyle
?
dateTimePickerTextStyle
,
})
{
})
{
return
CupertinoTextThemeData
.
_raw
(
return
CupertinoTextThemeData
.
_raw
(
_defaults
,
_defaults
,
...
@@ -282,9 +280,9 @@ class _TextThemeDefaultsBuilder {
...
@@ -282,9 +280,9 @@ class _TextThemeDefaultsBuilder {
final
Color
inactiveGrayColor
;
final
Color
inactiveGrayColor
;
static
TextStyle
_applyLabelColor
(
TextStyle
original
,
Color
color
)
{
static
TextStyle
_applyLabelColor
(
TextStyle
original
,
Color
color
)
{
return
original
?
.
color
==
color
return
original
.
color
==
color
?
original
?
original
:
original
?
.
copyWith
(
color:
color
);
:
original
.
copyWith
(
color:
color
);
}
}
TextStyle
get
textStyle
=>
_applyLabelColor
(
_kDefaultTextStyle
,
labelColor
);
TextStyle
get
textStyle
=>
_applyLabelColor
(
_kDefaultTextStyle
,
labelColor
);
...
@@ -294,12 +292,12 @@ class _TextThemeDefaultsBuilder {
...
@@ -294,12 +292,12 @@ class _TextThemeDefaultsBuilder {
TextStyle
get
pickerTextStyle
=>
_applyLabelColor
(
_kDefaultPickerTextStyle
,
labelColor
);
TextStyle
get
pickerTextStyle
=>
_applyLabelColor
(
_kDefaultPickerTextStyle
,
labelColor
);
TextStyle
get
dateTimePickerTextStyle
=>
_applyLabelColor
(
_kDefaultDateTimePickerTextStyle
,
labelColor
);
TextStyle
get
dateTimePickerTextStyle
=>
_applyLabelColor
(
_kDefaultDateTimePickerTextStyle
,
labelColor
);
TextStyle
actionTextStyle
({
Color
primaryColor
})
=>
_kDefaultActionTextStyle
.
copyWith
(
color:
primaryColor
);
TextStyle
actionTextStyle
({
Color
?
primaryColor
})
=>
_kDefaultActionTextStyle
.
copyWith
(
color:
primaryColor
);
TextStyle
navActionTextStyle
({
Color
primaryColor
})
=>
actionTextStyle
(
primaryColor:
primaryColor
);
TextStyle
navActionTextStyle
({
Color
?
primaryColor
})
=>
actionTextStyle
(
primaryColor:
primaryColor
);
_TextThemeDefaultsBuilder
resolveFrom
(
BuildContext
context
,
bool
nullOk
)
{
_TextThemeDefaultsBuilder
resolveFrom
(
BuildContext
context
,
bool
nullOk
)
{
final
Color
resolvedLabelColor
=
CupertinoDynamicColor
.
resolve
(
labelColor
,
context
,
nullOk:
nullOk
);
final
Color
resolvedLabelColor
=
CupertinoDynamicColor
.
resolve
(
labelColor
,
context
,
nullOk:
nullOk
)
!
;
final
Color
resolvedInactiveGray
=
CupertinoDynamicColor
.
resolve
(
inactiveGrayColor
,
context
,
nullOk:
nullOk
);
final
Color
resolvedInactiveGray
=
CupertinoDynamicColor
.
resolve
(
inactiveGrayColor
,
context
,
nullOk:
nullOk
)
!
;
return
resolvedLabelColor
==
labelColor
&&
resolvedInactiveGray
==
CupertinoColors
.
inactiveGray
return
resolvedLabelColor
==
labelColor
&&
resolvedInactiveGray
==
CupertinoColors
.
inactiveGray
?
this
?
this
:
_TextThemeDefaultsBuilder
(
resolvedLabelColor
,
resolvedInactiveGray
);
:
_TextThemeDefaultsBuilder
(
resolvedLabelColor
,
resolvedInactiveGray
);
...
...
packages/flutter/lib/src/cupertino/theme.dart
View file @
69788322
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
@@ -52,9 +50,9 @@ class CupertinoTheme extends StatelessWidget {
...
@@ -52,9 +50,9 @@ class CupertinoTheme extends StatelessWidget {
///
///
/// The [data] and [child] parameters must not be null.
/// The [data] and [child] parameters must not be null.
const
CupertinoTheme
({
const
CupertinoTheme
({
Key
key
,
Key
?
key
,
@
required
this
.
data
,
required
this
.
data
,
@
required
this
.
child
,
required
this
.
child
,
})
:
assert
(
child
!=
null
),
})
:
assert
(
child
!=
null
),
assert
(
data
!=
null
),
assert
(
data
!=
null
),
super
(
key:
key
);
super
(
key:
key
);
...
@@ -69,8 +67,8 @@ class CupertinoTheme extends StatelessWidget {
...
@@ -69,8 +67,8 @@ class CupertinoTheme extends StatelessWidget {
/// Resolves all the colors defined in that [CupertinoThemeData] against the
/// Resolves all the colors defined in that [CupertinoThemeData] against the
/// given [BuildContext] on a best-effort basis.
/// given [BuildContext] on a best-effort basis.
static
CupertinoThemeData
of
(
BuildContext
context
)
{
static
CupertinoThemeData
of
(
BuildContext
context
)
{
final
_InheritedCupertinoTheme
inheritedTheme
=
context
.
dependOnInheritedWidgetOfExactType
<
_InheritedCupertinoTheme
>();
final
_InheritedCupertinoTheme
?
inheritedTheme
=
context
.
dependOnInheritedWidgetOfExactType
<
_InheritedCupertinoTheme
>();
return
(
inheritedTheme
?.
theme
?
.
data
??
const
CupertinoThemeData
()).
resolveFrom
(
context
,
nullOk:
true
);
return
(
inheritedTheme
?.
theme
.
data
??
const
CupertinoThemeData
()).
resolveFrom
(
context
,
nullOk:
true
);
}
}
/// Retrieves the [Brightness] to use for descendant Cupertino widgets, based
/// Retrieves the [Brightness] to use for descendant Cupertino widgets, based
...
@@ -86,9 +84,9 @@ class CupertinoTheme extends StatelessWidget {
...
@@ -86,9 +84,9 @@ class CupertinoTheme extends StatelessWidget {
///
///
/// * [CupertinoThemeData.brightness], the property takes precedence over
/// * [CupertinoThemeData.brightness], the property takes precedence over
/// [MediaQueryData.platformBrightness] for descendant Cupertino widgets.
/// [MediaQueryData.platformBrightness] for descendant Cupertino widgets.
static
Brightness
brightnessOf
(
BuildContext
context
,
{
bool
nullOk
=
false
})
{
static
Brightness
?
brightnessOf
(
BuildContext
context
,
{
bool
nullOk
=
false
})
{
final
_InheritedCupertinoTheme
inheritedTheme
=
context
.
dependOnInheritedWidgetOfExactType
<
_InheritedCupertinoTheme
>();
final
_InheritedCupertinoTheme
?
inheritedTheme
=
context
.
dependOnInheritedWidgetOfExactType
<
_InheritedCupertinoTheme
>();
return
inheritedTheme
?.
theme
?.
data
?
.
brightness
??
MediaQuery
.
of
(
context
,
nullOk:
nullOk
)?.
platformBrightness
;
return
inheritedTheme
?.
theme
.
data
.
brightness
??
MediaQuery
.
of
(
context
,
nullOk:
nullOk
)?.
platformBrightness
;
}
}
/// The widget below this widget in the tree.
/// The widget below this widget in the tree.
...
@@ -116,9 +114,9 @@ class CupertinoTheme extends StatelessWidget {
...
@@ -116,9 +114,9 @@ class CupertinoTheme extends StatelessWidget {
class
_InheritedCupertinoTheme
extends
InheritedWidget
{
class
_InheritedCupertinoTheme
extends
InheritedWidget
{
const
_InheritedCupertinoTheme
({
const
_InheritedCupertinoTheme
({
Key
key
,
Key
?
key
,
@
required
this
.
theme
,
required
this
.
theme
,
@
required
Widget
child
,
required
Widget
child
,
})
:
assert
(
theme
!=
null
),
})
:
assert
(
theme
!=
null
),
super
(
key:
key
,
child:
child
);
super
(
key:
key
,
child:
child
);
...
@@ -150,12 +148,12 @@ class CupertinoThemeData with Diagnosticable {
...
@@ -150,12 +148,12 @@ class CupertinoThemeData with Diagnosticable {
///
///
/// Unspecified parameters default to a reasonable iOS default style.
/// Unspecified parameters default to a reasonable iOS default style.
const
CupertinoThemeData
({
const
CupertinoThemeData
({
Brightness
brightness
,
Brightness
?
brightness
,
Color
primaryColor
,
Color
?
primaryColor
,
Color
primaryContrastingColor
,
Color
?
primaryContrastingColor
,
CupertinoTextThemeData
textTheme
,
CupertinoTextThemeData
?
textTheme
,
Color
barBackgroundColor
,
Color
?
barBackgroundColor
,
Color
scaffoldBackgroundColor
,
Color
?
scaffoldBackgroundColor
,
})
:
this
.
raw
(
})
:
this
.
raw
(
brightness
,
brightness
,
primaryColor
,
primaryColor
,
...
@@ -171,12 +169,12 @@ class CupertinoThemeData with Diagnosticable {
...
@@ -171,12 +169,12 @@ class CupertinoThemeData with Diagnosticable {
/// Used by subclasses to get the superclass's defaulting behaviors.
/// Used by subclasses to get the superclass's defaulting behaviors.
@protected
@protected
const
CupertinoThemeData
.
raw
(
const
CupertinoThemeData
.
raw
(
Brightness
brightness
,
Brightness
?
brightness
,
Color
primaryColor
,
Color
?
primaryColor
,
Color
primaryContrastingColor
,
Color
?
primaryContrastingColor
,
CupertinoTextThemeData
textTheme
,
CupertinoTextThemeData
?
textTheme
,
Color
barBackgroundColor
,
Color
?
barBackgroundColor
,
Color
scaffoldBackgroundColor
,
Color
?
scaffoldBackgroundColor
,
)
:
this
.
_rawWithDefaults
(
)
:
this
.
_rawWithDefaults
(
brightness
,
brightness
,
primaryColor
,
primaryColor
,
...
@@ -197,7 +195,7 @@ class CupertinoThemeData with Diagnosticable {
...
@@ -197,7 +195,7 @@ class CupertinoThemeData with Diagnosticable {
this
.
_defaults
,
this
.
_defaults
,
);
);
final
_CupertinoThemeDefaults
_defaults
;
final
_CupertinoThemeDefaults
?
_defaults
;
/// The brightness override for Cupertino descendants.
/// The brightness override for Cupertino descendants.
///
///
...
@@ -215,7 +213,7 @@ class CupertinoThemeData with Diagnosticable {
...
@@ -215,7 +213,7 @@ class CupertinoThemeData with Diagnosticable {
///
///
/// * [CupertinoTheme.brightnessOf], a method used to retrieve the overall
/// * [CupertinoTheme.brightnessOf], a method used to retrieve the overall
/// [Brightness] from a [BuildContext], for Cupertino widgets.
/// [Brightness] from a [BuildContext], for Cupertino widgets.
final
Brightness
brightness
;
final
Brightness
?
brightness
;
/// A color used on interactive elements of the theme.
/// A color used on interactive elements of the theme.
///
///
...
@@ -232,8 +230,8 @@ class CupertinoThemeData with Diagnosticable {
...
@@ -232,8 +230,8 @@ class CupertinoThemeData with Diagnosticable {
///
///
/// * [MaterialBasedCupertinoThemeData], a [CupertinoThemeData] that defers
/// * [MaterialBasedCupertinoThemeData], a [CupertinoThemeData] that defers
/// [primaryColor] to its Material [Theme] parent if it's unspecified.
/// [primaryColor] to its Material [Theme] parent if it's unspecified.
Color
get
primaryColor
=>
_primaryColor
??
_defaults
.
primaryColor
;
Color
?
get
primaryColor
=>
_primaryColor
??
_defaults
!
.
primaryColor
;
final
Color
_primaryColor
;
final
Color
?
_primaryColor
;
/// A color that must be easy to see when rendered on a [primaryColor] background.
/// A color that must be easy to see when rendered on a [primaryColor] background.
///
///
...
@@ -247,29 +245,29 @@ class CupertinoThemeData with Diagnosticable {
...
@@ -247,29 +245,29 @@ class CupertinoThemeData with Diagnosticable {
///
///
/// * [MaterialBasedCupertinoThemeData], a [CupertinoThemeData] that defers
/// * [MaterialBasedCupertinoThemeData], a [CupertinoThemeData] that defers
/// [primaryContrastingColor] to its Material [Theme] parent if it's unspecified.
/// [primaryContrastingColor] to its Material [Theme] parent if it's unspecified.
Color
get
primaryContrastingColor
=>
_primaryContrastingColor
??
_defaults
.
primaryContrastingColor
;
Color
?
get
primaryContrastingColor
=>
_primaryContrastingColor
??
_defaults
!
.
primaryContrastingColor
;
final
Color
_primaryContrastingColor
;
final
Color
?
_primaryContrastingColor
;
/// Text styles used by Cupertino widgets.
/// Text styles used by Cupertino widgets.
///
///
/// Derived from [primaryColor] if unspecified.
/// Derived from [primaryColor] if unspecified.
CupertinoTextThemeData
get
textTheme
{
CupertinoTextThemeData
?
get
textTheme
{
return
_textTheme
??
_defaults
.
textThemeDefaults
.
createDefaults
(
primaryColor:
primaryColor
);
return
_textTheme
??
_defaults
!.
textThemeDefaults
.
createDefaults
(
primaryColor:
primaryColor
!
);
}
}
final
CupertinoTextThemeData
_textTheme
;
final
CupertinoTextThemeData
?
_textTheme
;
/// Background color of the top nav bar and bottom tab bar.
/// Background color of the top nav bar and bottom tab bar.
///
///
/// Defaults to a light gray in light mode, or a dark translucent gray color in
/// Defaults to a light gray in light mode, or a dark translucent gray color in
/// dark mode.
/// dark mode.
Color
get
barBackgroundColor
=>
_barBackgroundColor
??
_defaults
.
barBackgroundColor
;
Color
?
get
barBackgroundColor
=>
_barBackgroundColor
??
_defaults
!
.
barBackgroundColor
;
final
Color
_barBackgroundColor
;
final
Color
?
_barBackgroundColor
;
/// Background color of the scaffold.
/// Background color of the scaffold.
///
///
/// Defaults to [CupertinoColors.systemBackground].
/// Defaults to [CupertinoColors.systemBackground].
Color
get
scaffoldBackgroundColor
=>
_scaffoldBackgroundColor
??
_defaults
.
scaffoldBackgroundColor
;
Color
?
get
scaffoldBackgroundColor
=>
_scaffoldBackgroundColor
??
_defaults
!
.
scaffoldBackgroundColor
;
final
Color
_scaffoldBackgroundColor
;
final
Color
?
_scaffoldBackgroundColor
;
/// Returns an instance of the [CupertinoThemeData] whose property getters
/// Returns an instance of the [CupertinoThemeData] whose property getters
/// only return the construction time specifications with no derived values.
/// only return the construction time specifications with no derived values.
...
@@ -294,7 +292,7 @@ class CupertinoThemeData with Diagnosticable {
...
@@ -294,7 +292,7 @@ class CupertinoThemeData with Diagnosticable {
/// [CupertinoThemeData].
/// [CupertinoThemeData].
@protected
@protected
CupertinoThemeData
resolveFrom
(
BuildContext
context
,
{
bool
nullOk
=
false
})
{
CupertinoThemeData
resolveFrom
(
BuildContext
context
,
{
bool
nullOk
=
false
})
{
Color
convertColor
(
Color
color
)
=>
CupertinoDynamicColor
.
resolve
(
color
,
context
,
nullOk:
nullOk
);
Color
?
convertColor
(
Color
?
color
)
=>
CupertinoDynamicColor
.
resolve
(
color
,
context
,
nullOk:
nullOk
);
return
CupertinoThemeData
.
_rawWithDefaults
(
return
CupertinoThemeData
.
_rawWithDefaults
(
brightness
,
brightness
,
...
@@ -303,7 +301,7 @@ class CupertinoThemeData with Diagnosticable {
...
@@ -303,7 +301,7 @@ class CupertinoThemeData with Diagnosticable {
_textTheme
?.
resolveFrom
(
context
,
nullOk:
nullOk
),
_textTheme
?.
resolveFrom
(
context
,
nullOk:
nullOk
),
convertColor
(
_barBackgroundColor
),
convertColor
(
_barBackgroundColor
),
convertColor
(
_scaffoldBackgroundColor
),
convertColor
(
_scaffoldBackgroundColor
),
_defaults
.
resolveFrom
(
context
,
_textTheme
==
null
,
nullOk:
nullOk
),
_defaults
!
.
resolveFrom
(
context
,
_textTheme
==
null
,
nullOk:
nullOk
),
);
);
}
}
...
@@ -315,12 +313,12 @@ class CupertinoThemeData with Diagnosticable {
...
@@ -315,12 +313,12 @@ class CupertinoThemeData with Diagnosticable {
/// copying with a different [primaryColor] will also change the copy's implied
/// copying with a different [primaryColor] will also change the copy's implied
/// [textTheme].
/// [textTheme].
CupertinoThemeData
copyWith
({
CupertinoThemeData
copyWith
({
Brightness
brightness
,
Brightness
?
brightness
,
Color
primaryColor
,
Color
?
primaryColor
,
Color
primaryContrastingColor
,
Color
?
primaryContrastingColor
,
CupertinoTextThemeData
textTheme
,
CupertinoTextThemeData
?
textTheme
,
Color
barBackgroundColor
,
Color
?
barBackgroundColor
,
Color
scaffoldBackgroundColor
,
Color
?
scaffoldBackgroundColor
,
})
{
})
{
return
CupertinoThemeData
.
_rawWithDefaults
(
return
CupertinoThemeData
.
_rawWithDefaults
(
brightness
??
this
.
brightness
,
brightness
??
this
.
brightness
,
...
@@ -342,13 +340,13 @@ class CupertinoThemeData with Diagnosticable {
...
@@ -342,13 +340,13 @@ class CupertinoThemeData with Diagnosticable {
properties
.
add
(
createCupertinoColorProperty
(
'primaryContrastingColor'
,
primaryContrastingColor
,
defaultValue:
defaultData
.
primaryContrastingColor
));
properties
.
add
(
createCupertinoColorProperty
(
'primaryContrastingColor'
,
primaryContrastingColor
,
defaultValue:
defaultData
.
primaryContrastingColor
));
properties
.
add
(
createCupertinoColorProperty
(
'barBackgroundColor'
,
barBackgroundColor
,
defaultValue:
defaultData
.
barBackgroundColor
));
properties
.
add
(
createCupertinoColorProperty
(
'barBackgroundColor'
,
barBackgroundColor
,
defaultValue:
defaultData
.
barBackgroundColor
));
properties
.
add
(
createCupertinoColorProperty
(
'scaffoldBackgroundColor'
,
scaffoldBackgroundColor
,
defaultValue:
defaultData
.
scaffoldBackgroundColor
));
properties
.
add
(
createCupertinoColorProperty
(
'scaffoldBackgroundColor'
,
scaffoldBackgroundColor
,
defaultValue:
defaultData
.
scaffoldBackgroundColor
));
textTheme
.
debugFillProperties
(
properties
);
textTheme
!
.
debugFillProperties
(
properties
);
}
}
}
}
class
_NoDefaultCupertinoThemeData
extends
CupertinoThemeData
{
class
_NoDefaultCupertinoThemeData
extends
CupertinoThemeData
{
const
_NoDefaultCupertinoThemeData
(
const
_NoDefaultCupertinoThemeData
(
Brightness
brightness
,
Brightness
?
brightness
,
this
.
primaryColor
,
this
.
primaryColor
,
this
.
primaryContrastingColor
,
this
.
primaryContrastingColor
,
this
.
textTheme
,
this
.
textTheme
,
...
@@ -365,19 +363,19 @@ class _NoDefaultCupertinoThemeData extends CupertinoThemeData {
...
@@ -365,19 +363,19 @@ class _NoDefaultCupertinoThemeData extends CupertinoThemeData {
);
);
@override
@override
final
Color
primaryColor
;
final
Color
?
primaryColor
;
@override
@override
final
Color
primaryContrastingColor
;
final
Color
?
primaryContrastingColor
;
@override
@override
final
CupertinoTextThemeData
textTheme
;
final
CupertinoTextThemeData
?
textTheme
;
@override
@override
final
Color
barBackgroundColor
;
final
Color
?
barBackgroundColor
;
@override
@override
final
Color
scaffoldBackgroundColor
;
final
Color
?
scaffoldBackgroundColor
;
@override
@override
_NoDefaultCupertinoThemeData
resolveFrom
(
BuildContext
context
,
{
bool
nullOk
=
false
})
{
_NoDefaultCupertinoThemeData
resolveFrom
(
BuildContext
context
,
{
bool
nullOk
=
false
})
{
Color
convertColor
(
Color
color
)
=>
CupertinoDynamicColor
.
resolve
(
color
,
context
,
nullOk:
nullOk
);
Color
?
convertColor
(
Color
?
color
)
=>
CupertinoDynamicColor
.
resolve
(
color
,
context
,
nullOk:
nullOk
);
return
_NoDefaultCupertinoThemeData
(
return
_NoDefaultCupertinoThemeData
(
brightness
,
brightness
,
...
@@ -391,12 +389,12 @@ class _NoDefaultCupertinoThemeData extends CupertinoThemeData {
...
@@ -391,12 +389,12 @@ class _NoDefaultCupertinoThemeData extends CupertinoThemeData {
@override
@override
CupertinoThemeData
copyWith
({
CupertinoThemeData
copyWith
({
Brightness
brightness
,
Brightness
?
brightness
,
Color
primaryColor
,
Color
?
primaryColor
,
Color
primaryContrastingColor
,
Color
?
primaryContrastingColor
,
CupertinoTextThemeData
textTheme
,
CupertinoTextThemeData
?
textTheme
,
Color
barBackgroundColor
,
Color
?
barBackgroundColor
,
Color
scaffoldBackgroundColor
,
Color
?
scaffoldBackgroundColor
,
})
{
})
{
return
_NoDefaultCupertinoThemeData
(
return
_NoDefaultCupertinoThemeData
(
brightness
??
this
.
brightness
,
brightness
??
this
.
brightness
,
...
@@ -420,16 +418,16 @@ class _CupertinoThemeDefaults {
...
@@ -420,16 +418,16 @@ class _CupertinoThemeDefaults {
this
.
textThemeDefaults
,
this
.
textThemeDefaults
,
);
);
final
Brightness
brightness
;
final
Brightness
?
brightness
;
final
Color
primaryColor
;
final
Color
primaryColor
;
final
Color
primaryContrastingColor
;
final
Color
primaryContrastingColor
;
final
Color
barBackgroundColor
;
final
Color
barBackgroundColor
;
final
Color
scaffoldBackgroundColor
;
final
Color
scaffoldBackgroundColor
;
final
_CupertinoTextThemeDefaults
textThemeDefaults
;
final
_CupertinoTextThemeDefaults
textThemeDefaults
;
_CupertinoThemeDefaults
resolveFrom
(
BuildContext
context
,
bool
resolveTextTheme
,
{
@
required
bool
nullOk
})
{
_CupertinoThemeDefaults
resolveFrom
(
BuildContext
context
,
bool
resolveTextTheme
,
{
required
bool
nullOk
})
{
assert
(
nullOk
!=
null
);
assert
(
nullOk
!=
null
);
Color
convertColor
(
Color
color
)
=>
CupertinoDynamicColor
.
resolve
(
color
,
context
,
nullOk:
nullOk
);
Color
convertColor
(
Color
color
)
=>
CupertinoDynamicColor
.
resolve
(
color
,
context
,
nullOk:
nullOk
)
!
;
return
_CupertinoThemeDefaults
(
return
_CupertinoThemeDefaults
(
brightness
,
brightness
,
...
@@ -437,7 +435,7 @@ class _CupertinoThemeDefaults {
...
@@ -437,7 +435,7 @@ class _CupertinoThemeDefaults {
convertColor
(
primaryContrastingColor
),
convertColor
(
primaryContrastingColor
),
convertColor
(
barBackgroundColor
),
convertColor
(
barBackgroundColor
),
convertColor
(
scaffoldBackgroundColor
),
convertColor
(
scaffoldBackgroundColor
),
resolveTextTheme
?
textThemeDefaults
?
.
resolveFrom
(
context
,
nullOk:
nullOk
)
:
textThemeDefaults
,
resolveTextTheme
?
textThemeDefaults
.
resolveFrom
(
context
,
nullOk:
nullOk
)
:
textThemeDefaults
,
);
);
}
}
}
}
...
@@ -452,14 +450,14 @@ class _CupertinoTextThemeDefaults {
...
@@ -452,14 +450,14 @@ class _CupertinoTextThemeDefaults {
final
Color
labelColor
;
final
Color
labelColor
;
final
Color
inactiveGray
;
final
Color
inactiveGray
;
_CupertinoTextThemeDefaults
resolveFrom
(
BuildContext
context
,
{
@
required
bool
nullOk
})
{
_CupertinoTextThemeDefaults
resolveFrom
(
BuildContext
context
,
{
required
bool
nullOk
})
{
return
_CupertinoTextThemeDefaults
(
return
_CupertinoTextThemeDefaults
(
CupertinoDynamicColor
.
resolve
(
labelColor
,
context
,
nullOk:
nullOk
),
CupertinoDynamicColor
.
resolve
(
labelColor
,
context
,
nullOk:
nullOk
)
!
,
CupertinoDynamicColor
.
resolve
(
inactiveGray
,
context
,
nullOk:
nullOk
),
CupertinoDynamicColor
.
resolve
(
inactiveGray
,
context
,
nullOk:
nullOk
)
!
,
);
);
}
}
CupertinoTextThemeData
createDefaults
({
@
required
Color
primaryColor
})
{
CupertinoTextThemeData
createDefaults
({
required
Color
primaryColor
})
{
assert
(
primaryColor
!=
null
);
assert
(
primaryColor
!=
null
);
return
_DefaultCupertinoTextThemeData
(
return
_DefaultCupertinoTextThemeData
(
primaryColor:
primaryColor
,
primaryColor:
primaryColor
,
...
@@ -474,9 +472,9 @@ class _CupertinoTextThemeDefaults {
...
@@ -474,9 +472,9 @@ class _CupertinoTextThemeDefaults {
// text styles changes.
// text styles changes.
class
_DefaultCupertinoTextThemeData
extends
CupertinoTextThemeData
{
class
_DefaultCupertinoTextThemeData
extends
CupertinoTextThemeData
{
const
_DefaultCupertinoTextThemeData
({
const
_DefaultCupertinoTextThemeData
({
@
required
this
.
labelColor
,
required
this
.
labelColor
,
@
required
this
.
inactiveGray
,
required
this
.
inactiveGray
,
@
required
Color
primaryColor
,
required
Color
primaryColor
,
})
:
assert
(
labelColor
!=
null
),
})
:
assert
(
labelColor
!=
null
),
assert
(
inactiveGray
!=
null
),
assert
(
inactiveGray
!=
null
),
assert
(
primaryColor
!=
null
),
assert
(
primaryColor
!=
null
),
...
...
packages/flutter/test/cupertino/colors_test.dart
View file @
69788322
...
@@ -167,7 +167,7 @@ void main() {
...
@@ -167,7 +167,7 @@ void main() {
});
});
test
(
'can resolve null color'
,
()
{
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'
,
()
{
test
(
'withVibrancy constructor creates colors that may depend on vibrancy'
,
()
{
...
@@ -589,3 +589,20 @@ void main() {
...
@@ -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