diff --git a/packages/flutter/lib/src/cupertino/colors.dart b/packages/flutter/lib/src/cupertino/colors.dart index 0c84b42773..a3ec013734 100644 --- a/packages/flutter/lib/src/cupertino/colors.dart +++ b/packages/flutter/lib/src/cupertino/colors.dart @@ -76,6 +76,13 @@ abstract final class CupertinoColors { /// * [white], opaque white in the [CupertinoColors] palette. static const Color black = Color(0xFF000000); + /// A fully-transparent color, completely invisible. + /// + /// See also: + /// + /// * [material.Colors.transparent], the same color, in the Material Design palette. + static const Color transparent = Color(0x00000000); + /// Used in iOS 10 for light background fills such as the chat bubble background. /// /// This is SystemLightGrayColor in the iOS palette. diff --git a/packages/flutter/lib/src/cupertino/route.dart b/packages/flutter/lib/src/cupertino/route.dart index eb96c18ca9..ce625a6c15 100644 --- a/packages/flutter/lib/src/cupertino/route.dart +++ b/packages/flutter/lib/src/cupertino/route.dart @@ -854,7 +854,7 @@ class _CupertinoEdgeShadowDecoration extends Decoration { // Eyeballed gradient used to mimic a drop shadow on the start side only. [ Color(0x04000000), - Color(0x00000000), + CupertinoColors.transparent, ], ), ); diff --git a/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart b/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart index 22cdd554a0..2672cc2588 100644 --- a/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart +++ b/packages/flutter/lib/src/cupertino/text_selection_toolbar.dart @@ -465,7 +465,7 @@ class _RenderCupertinoTextSelectionToolbarShape extends RenderShiftedBox { ..shader = ui.Gradient.linear( Offset.zero, const Offset(10.0, 10.0), - const [Color(0x00000000), Color(0xFFFF00FF), Color(0xFFFF00FF), Color(0x00000000)], + const [CupertinoColors.transparent, Color(0xFFFF00FF), Color(0xFFFF00FF), CupertinoColors.transparent], const [0.25, 0.25, 0.75, 0.75], TileMode.repeated, ) diff --git a/packages/flutter/lib/src/cupertino/text_selection_toolbar_button.dart b/packages/flutter/lib/src/cupertino/text_selection_toolbar_button.dart index 06723a6b2e..1507f3073e 100644 --- a/packages/flutter/lib/src/cupertino/text_selection_toolbar_button.dart +++ b/packages/flutter/lib/src/cupertino/text_selection_toolbar_button.dart @@ -132,9 +132,9 @@ class _CupertinoTextSelectionToolbarButtonState extends State expectedColors = [null, Color(0x00000000)]; - // `Color(0x00000000)` -> Is `Colors.transparent`. + // `Color(0x00000000)` -> Is `CupertinoColors.transparent`. // `null` -> Default when no color argument is given in `BoxDecoration`. // Any other color won't preserve the child's property. expect(expectedColors, contains(boxDecoration?.color)); diff --git a/packages/flutter/test/cupertino/route_test.dart b/packages/flutter/test/cupertino/route_test.dart index 649efb25a5..8749da1f69 100644 --- a/packages/flutter/test/cupertino/route_test.dart +++ b/packages/flutter/test/cupertino/route_test.dart @@ -1489,11 +1489,11 @@ void main() { final RenderBox box = tester.firstRenderObject(find.byType(CustomPaint)); // Animation starts with effectively no shadow - expect(box, paintsShadowRect(dx: 795, color: const Color(0x00000000))); - expect(box, paintsShadowRect(dx: 785, color: const Color(0x00000000))); - expect(box, paintsShadowRect(dx: 775, color: const Color(0x00000000))); - expect(box, paintsShadowRect(dx: 765, color: const Color(0x00000000))); - expect(box, paintsShadowRect(dx: 755, color: const Color(0x00000000))); + expect(box, paintsShadowRect(dx: 795, color: CupertinoColors.transparent)); + expect(box, paintsShadowRect(dx: 785, color: CupertinoColors.transparent)); + expect(box, paintsShadowRect(dx: 775, color: CupertinoColors.transparent)); + expect(box, paintsShadowRect(dx: 765, color: CupertinoColors.transparent)); + expect(box, paintsShadowRect(dx: 755, color: CupertinoColors.transparent)); await tester.pump(const Duration(milliseconds: 100)); @@ -1501,8 +1501,8 @@ void main() { expect(box, paintsShadowRect(dx: 296, color: const Color(0x03000000))); expect(box, paintsShadowRect(dx: 286, color: const Color(0x02000000))); expect(box, paintsShadowRect(dx: 276, color: const Color(0x01000000))); - expect(box, paintsShadowRect(dx: 266, color: const Color(0x00000000))); - expect(box, paintsShadowRect(dx: 266, color: const Color(0x00000000))); + expect(box, paintsShadowRect(dx: 266, color: CupertinoColors.transparent)); + expect(box, paintsShadowRect(dx: 266, color: CupertinoColors.transparent)); await tester.pumpAndSettle(); @@ -1512,7 +1512,7 @@ void main() { expect(box, paintsShadowRect(dx: -10, color: const Color(0x03000000))); expect(box, paintsShadowRect(dx: -20, color: const Color(0x02000000))); expect(box, paintsShadowRect(dx: -30, color: const Color(0x01000000))); - expect(box, paintsShadowRect(dx: -40, color: const Color(0x00000000))); + expect(box, paintsShadowRect(dx: -40, color: CupertinoColors.transparent)); // Start animation in reverse tester.state(find.byType(Navigator)).pop(); @@ -1523,16 +1523,16 @@ void main() { expect(box, paintsShadowRect(dx: 488, color: const Color(0x03000000))); expect(box, paintsShadowRect(dx: 478, color: const Color(0x02000000))); expect(box, paintsShadowRect(dx: 468, color: const Color(0x01000000))); - expect(box, paintsShadowRect(dx: 458, color: const Color(0x00000000))); + expect(box, paintsShadowRect(dx: 458, color: CupertinoColors.transparent)); await tester.pump(const Duration(milliseconds: 150)); // At the end of the animation, the shadow approaches full transparency expect(box, paintsShadowRect(dx: 794, color: const Color(0x01000000))); - expect(box, paintsShadowRect(dx: 784, color: const Color(0x00000000))); - expect(box, paintsShadowRect(dx: 774, color: const Color(0x00000000))); - expect(box, paintsShadowRect(dx: 764, color: const Color(0x00000000))); - expect(box, paintsShadowRect(dx: 754, color: const Color(0x00000000))); + expect(box, paintsShadowRect(dx: 784, color: CupertinoColors.transparent)); + expect(box, paintsShadowRect(dx: 774, color: CupertinoColors.transparent)); + expect(box, paintsShadowRect(dx: 764, color: CupertinoColors.transparent)); + expect(box, paintsShadowRect(dx: 754, color: CupertinoColors.transparent)); }); testWidgets('when route is fullscreenDialog, it has no visible _CupertinoEdgeShadowDecoration', (WidgetTester tester) async { @@ -2020,8 +2020,6 @@ void main() { }); testWidgets('showCupertinoModalPopup transparent barrier color is transparent', (WidgetTester tester) async { - const Color kTransparentColor = Color(0x00000000); - await tester.pumpWidget(CupertinoApp( home: CupertinoPageScaffold( child: Builder(builder: (BuildContext context) { @@ -2030,7 +2028,7 @@ void main() { await showCupertinoModalPopup( context: context, builder: (BuildContext context) => const SizedBox(), - barrierColor: kTransparentColor, + barrierColor: CupertinoColors.transparent, ); }, child: const Text('tap'), diff --git a/packages/flutter/test/cupertino/text_selection_toolbar_button_test.dart b/packages/flutter/test/cupertino/text_selection_toolbar_button_test.dart index 76eee86317..5756e231c0 100644 --- a/packages/flutter/test/cupertino/text_selection_toolbar_button_test.dart +++ b/packages/flutter/test/cupertino/text_selection_toolbar_button_test.dart @@ -47,7 +47,7 @@ void main() { matching: find.byType(DecoratedBox), )); BoxDecoration boxDecoration = decoratedBox.decoration as BoxDecoration; - expect(boxDecoration.color, const Color(0x00000000)); + expect(boxDecoration.color, CupertinoColors.transparent); // Make a "down" gesture on the button. final Offset center = tester.getCenter(find.byType(CupertinoTextSelectionToolbarButton)); @@ -72,7 +72,7 @@ void main() { matching: find.byType(DecoratedBox), )); boxDecoration = decoratedBox.decoration as BoxDecoration; - expect(boxDecoration.color, const Color(0x00000000)); + expect(boxDecoration.color, CupertinoColors.transparent); }); testWidgets('passing null to onPressed disables the button', (WidgetTester tester) async { diff --git a/packages/flutter/test/cupertino/theme_test.dart b/packages/flutter/test/cupertino/theme_test.dart index 5f8b9a372f..148462a978 100644 --- a/packages/flutter/test/cupertino/theme_test.dart +++ b/packages/flutter/test/cupertino/theme_test.dart @@ -205,7 +205,7 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/47651. expect( const CupertinoTheme( - data: CupertinoThemeData(primaryColor: Color(0x00000000)), + data: CupertinoThemeData(primaryColor: CupertinoColors.transparent), child: SizedBox(), ).toStringDeep().trimRight(), isNot(contains('\n')),