Unverified Commit 743960df authored by jslavitz's avatar jslavitz Committed by GitHub

Cupertino picker null color fix (#24529)

*null fix and test
parent 9d81c67a
...@@ -215,7 +215,7 @@ class _CupertinoPickerState extends State<CupertinoPicker> { ...@@ -215,7 +215,7 @@ class _CupertinoPickerState extends State<CupertinoPicker> {
if (widget.backgroundColor != null && widget.backgroundColor.alpha < 255) if (widget.backgroundColor != null && widget.backgroundColor.alpha < 255)
return Container(); return Container();
final Color widgetBackgroundColor = widget.backgroundColor; final Color widgetBackgroundColor = widget.backgroundColor ?? const Color(0xFFFFFFFF);
return Positioned.fill( return Positioned.fill(
child: IgnorePointer( child: IgnorePointer(
child: Container( child: Container(
......
...@@ -132,6 +132,49 @@ void main() { ...@@ -132,6 +132,49 @@ void main() {
expect(boxDecoration.gradient, isNull); expect(boxDecoration.gradient, isNull);
expect(boxDecoration.color, isNotNull); expect(boxDecoration.color, isNotNull);
}); });
testWidgets('gradient displays correctly with null background color', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
child: Align(
alignment: Alignment.topLeft,
child: SizedBox(
height: 300.0,
width: 300.0,
child: CupertinoPicker(
backgroundColor: null,
itemExtent: 15.0,
children: const <Widget>[
Text('1'),
Text('1'),
Text('1'),
Text('1'),
Text('1'),
Text('1'),
Text('1'),
],
onSelectedItemChanged: (int i) {},
),
),
),
),
);
// If the background color is null, the gradient color should be white.
const Color backgroundColor = Color(0xFFFFFFFF);
final Container container = tester.firstWidget(find.byType(Container));
final BoxDecoration boxDecoration = container.decoration;
expect(boxDecoration.gradient.colors, <Color>[
backgroundColor,
backgroundColor.withAlpha(0xF2),
backgroundColor.withAlpha(0xDD),
backgroundColor.withAlpha(0x00),
backgroundColor.withAlpha(0x00),
backgroundColor.withAlpha(0xDD),
backgroundColor.withAlpha(0xF2),
backgroundColor,
]);
});
}); });
group('scroll', () { group('scroll', () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment