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
97d273ce
Unverified
Commit
97d273ce
authored
Feb 01, 2023
by
Callum Moffat
Committed by
GitHub
Feb 01, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CupertinoThemeData equality (#119480)
parent
e1f0b1d1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
2 deletions
+94
-2
text_theme.dart
packages/flutter/lib/src/cupertino/text_theme.dart
+51
-0
theme.dart
packages/flutter/lib/src/cupertino/theme.dart
+29
-0
theme_test.dart
packages/flutter/test/cupertino/theme_test.dart
+12
-0
theme_test.dart
packages/flutter/test/material/theme_test.dart
+2
-2
No files found.
packages/flutter/lib/src/cupertino/text_theme.dart
View file @
97d273ce
...
...
@@ -260,6 +260,41 @@ class CupertinoTextThemeData with Diagnosticable {
properties
.
add
(
DiagnosticsProperty
<
TextStyle
>(
'pickerTextStyle'
,
pickerTextStyle
,
defaultValue:
defaultData
.
pickerTextStyle
));
properties
.
add
(
DiagnosticsProperty
<
TextStyle
>(
'dateTimePickerTextStyle'
,
dateTimePickerTextStyle
,
defaultValue:
defaultData
.
dateTimePickerTextStyle
));
}
@override
bool
operator
==
(
Object
other
)
{
if
(
identical
(
this
,
other
))
{
return
true
;
}
if
(
other
.
runtimeType
!=
runtimeType
)
{
return
false
;
}
return
other
is
CupertinoTextThemeData
&&
other
.
_defaults
==
_defaults
&&
other
.
_primaryColor
==
_primaryColor
&&
other
.
_textStyle
==
_textStyle
&&
other
.
_actionTextStyle
==
_actionTextStyle
&&
other
.
_tabLabelTextStyle
==
_tabLabelTextStyle
&&
other
.
_navTitleTextStyle
==
_navTitleTextStyle
&&
other
.
_navLargeTitleTextStyle
==
_navLargeTitleTextStyle
&&
other
.
_navActionTextStyle
==
_navActionTextStyle
&&
other
.
_pickerTextStyle
==
_pickerTextStyle
&&
other
.
_dateTimePickerTextStyle
==
_dateTimePickerTextStyle
;
}
@override
int
get
hashCode
=>
Object
.
hash
(
_defaults
,
_primaryColor
,
_textStyle
,
_actionTextStyle
,
_tabLabelTextStyle
,
_navTitleTextStyle
,
_navLargeTitleTextStyle
,
_navActionTextStyle
,
_pickerTextStyle
,
_dateTimePickerTextStyle
,
);
}
...
...
@@ -296,4 +331,20 @@ class _TextThemeDefaultsBuilder {
?
this
:
_TextThemeDefaultsBuilder
(
resolvedLabelColor
,
resolvedInactiveGray
);
}
@override
bool
operator
==
(
Object
other
)
{
if
(
identical
(
this
,
other
))
{
return
true
;
}
if
(
other
.
runtimeType
!=
runtimeType
)
{
return
false
;
}
return
other
is
_TextThemeDefaultsBuilder
&&
other
.
labelColor
==
labelColor
&&
other
.
inactiveGrayColor
==
inactiveGrayColor
;
}
@override
int
get
hashCode
=>
Object
.
hash
(
labelColor
,
inactiveGrayColor
);
}
packages/flutter/lib/src/cupertino/theme.dart
View file @
97d273ce
...
...
@@ -311,6 +311,35 @@ class CupertinoThemeData extends NoDefaultCupertinoThemeData with Diagnosticable
properties
.
add
(
DiagnosticsProperty
<
bool
>(
'applyThemeToAll'
,
applyThemeToAll
,
defaultValue:
defaultData
.
applyThemeToAll
));
textTheme
.
debugFillProperties
(
properties
);
}
@override
bool
operator
==
(
Object
other
)
{
if
(
identical
(
this
,
other
))
{
return
true
;
}
if
(
other
.
runtimeType
!=
runtimeType
)
{
return
false
;
}
return
other
is
CupertinoThemeData
&&
other
.
brightness
==
brightness
&&
other
.
primaryColor
==
primaryColor
&&
other
.
primaryContrastingColor
==
primaryContrastingColor
&&
other
.
textTheme
==
textTheme
&&
other
.
barBackgroundColor
==
barBackgroundColor
&&
other
.
scaffoldBackgroundColor
==
scaffoldBackgroundColor
&&
other
.
applyThemeToAll
==
applyThemeToAll
;
}
@override
int
get
hashCode
=>
Object
.
hash
(
brightness
,
primaryColor
,
primaryContrastingColor
,
textTheme
,
barBackgroundColor
,
scaffoldBackgroundColor
,
applyThemeToAll
,
);
}
/// Styling specifications for a cupertino theme without default values for
...
...
packages/flutter/test/cupertino/theme_test.dart
View file @
97d273ce
...
...
@@ -212,6 +212,18 @@ void main() {
);
});
testWidgets
(
'CupertinoThemeData equality'
,
(
WidgetTester
tester
)
async
{
const
CupertinoThemeData
a
=
CupertinoThemeData
(
brightness:
Brightness
.
dark
);
final
CupertinoThemeData
b
=
a
.
copyWith
();
final
CupertinoThemeData
c
=
a
.
copyWith
(
brightness:
Brightness
.
light
);
expect
(
a
,
equals
(
b
));
expect
(
b
,
equals
(
a
));
expect
(
a
,
isNot
(
equals
(
c
)));
expect
(
c
,
isNot
(
equals
(
a
)));
expect
(
b
,
isNot
(
equals
(
c
)));
expect
(
c
,
isNot
(
equals
(
b
)));
});
late
Brightness
currentBrightness
;
void
colorMatches
(
Color
?
componentColor
,
CupertinoDynamicColor
expectedDynamicColor
)
{
switch
(
currentBrightness
)
{
...
...
packages/flutter/test/material/theme_test.dart
View file @
97d273ce
...
...
@@ -644,12 +644,12 @@ void main() {
primarySwatch:
Colors
.
blue
,
cupertinoOverrideTheme:
const
CupertinoThemeData
(
// But the primary material color is preempted by the override.
primaryColor:
CupertinoColors
.
activeOrange
,
primaryColor:
CupertinoColors
.
systemRed
,
),
));
expect
(
buildCount
,
2
);
expect
(
theme
.
primaryColor
,
CupertinoColors
.
activeOrange
);
expect
(
theme
.
primaryColor
,
CupertinoColors
.
systemRed
);
},
);
...
...
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