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
bd2ca58d
Unverified
Commit
bd2ca58d
authored
May 02, 2022
by
Taha Tesser
Committed by
GitHub
May 02, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `CupertinoPicker`dark mode text color (#100310)
Improved code
parent
f5865e5c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
1 deletion
+43
-1
picker.dart
packages/flutter/lib/src/cupertino/picker.dart
+2
-1
picker_test.dart
packages/flutter/test/cupertino/picker_test.dart
+41
-0
No files found.
packages/flutter/lib/src/cupertino/picker.dart
View file @
bd2ca58d
...
...
@@ -281,11 +281,12 @@ class _CupertinoPickerState extends State<CupertinoPicker> {
@override
Widget
build
(
BuildContext
context
)
{
final
TextStyle
textStyle
=
CupertinoTheme
.
of
(
context
).
textTheme
.
pickerTextStyle
;
final
Color
?
resolvedBackgroundColor
=
CupertinoDynamicColor
.
maybeResolve
(
widget
.
backgroundColor
,
context
);
assert
(
RenderListWheelViewport
.
defaultPerspective
==
_kDefaultPerspective
);
final
Widget
result
=
DefaultTextStyle
(
style:
CupertinoTheme
.
of
(
context
).
textTheme
.
pickerTextStyle
,
style:
textStyle
.
copyWith
(
color:
CupertinoDynamicColor
.
maybeResolve
(
textStyle
.
color
,
context
))
,
child:
Stack
(
children:
<
Widget
>[
Positioned
.
fill
(
...
...
packages/flutter/test/cupertino/picker_test.dart
View file @
bd2ca58d
...
...
@@ -3,6 +3,7 @@
// found in the LICENSE file.
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -423,6 +424,46 @@ void main() {
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
macOS
}));
});
testWidgets
(
'Picker adapts to MaterialApp dark mode'
,
(
WidgetTester
tester
)
async
{
Widget
_buildCupertinoPicker
(
Brightness
brightness
)
{
return
MaterialApp
(
theme:
ThemeData
(
brightness:
brightness
),
home:
Align
(
alignment:
Alignment
.
topLeft
,
child:
SizedBox
(
height:
300.0
,
width:
300.0
,
child:
CupertinoPicker
(
itemExtent:
50.0
,
onSelectedItemChanged:
(
_
)
{
},
children:
List
<
Widget
>.
generate
(
3
,
(
int
index
)
{
return
SizedBox
(
height:
50.0
,
width:
300.0
,
child:
Text
(
index
.
toString
()),
);
}),
),
),
),
);
}
// CupertinoPicker with light theme.
await
tester
.
pumpWidget
(
_buildCupertinoPicker
(
Brightness
.
light
));
RenderParagraph
paragraph
=
tester
.
renderObject
(
find
.
text
(
'1'
));
expect
(
paragraph
.
text
.
style
!.
color
,
CupertinoColors
.
label
);
// Text style should not return unresolved color.
expect
(
paragraph
.
text
.
style
!.
color
.
toString
().
contains
(
'UNRESOLVED'
),
isFalse
);
// CupertinoPicker with dark theme.
await
tester
.
pumpWidget
(
_buildCupertinoPicker
(
Brightness
.
dark
));
paragraph
=
tester
.
renderObject
(
find
.
text
(
'1'
));
expect
(
paragraph
.
text
.
style
!.
color
,
CupertinoColors
.
label
);
// Text style should not return unresolved color.
expect
(
paragraph
.
text
.
style
!.
color
.
toString
().
contains
(
'UNRESOLVED'
),
isFalse
);
});
group
(
'CupertinoPickerDefaultSelectionOverlay'
,
()
{
testWidgets
(
'should be using directional decoration'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
...
...
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