From 7a6c81a294f673137af69836a03c091f8285add3 Mon Sep 17 00:00:00 2001 From: Matan Lurey Date: Tue, 5 Nov 2024 16:07:08 -0800 Subject: [PATCH] Forward fix `CupertinoDynamicColor` by adding `toARGB32()`. (#158145) Unblocks landing https://github.com/flutter/engine/pull/56329. @jtmcdole monorepo can't come soon enough... --- .../flutter/lib/src/cupertino/colors.dart | 5 +++++ .../flutter/test/cupertino/colors_test.dart | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/packages/flutter/lib/src/cupertino/colors.dart b/packages/flutter/lib/src/cupertino/colors.dart index 5f1b4c2783..7425b59d42 100644 --- a/packages/flutter/lib/src/cupertino/colors.dart +++ b/packages/flutter/lib/src/cupertino/colors.dart @@ -1149,6 +1149,11 @@ class CupertinoDynamicColor with Diagnosticable implements Color { @override int get value => _effectiveColor.value; + @override + // TODO(matanl): Remove once https://github.com/flutter/engine/pull/56329 lands in the framework. + // ignore: override_on_non_overriding_member, public_member_api_docs + int toARGB32() => value; + @override int get alpha => _effectiveColor.alpha; diff --git a/packages/flutter/test/cupertino/colors_test.dart b/packages/flutter/test/cupertino/colors_test.dart index d42f411807..164edde0fc 100644 --- a/packages/flutter/test/cupertino/colors_test.dart +++ b/packages/flutter/test/cupertino/colors_test.dart @@ -413,6 +413,26 @@ void main() { expect(find.byType(DependentWidget), paints..rect(color: color7)); }); + testWidgets('CupertinoDynamicColor toARGB32() is the same as value', (WidgetTester tester) async { + late CupertinoDynamicColor color; + await tester.pumpWidget( + CupertinoApp( + theme: const CupertinoThemeData( + brightness: Brightness.dark, + primaryColor: dynamicColor, + ), + home: Builder( + builder: (BuildContext context) { + color = CupertinoTheme.of(context).primaryColor as CupertinoDynamicColor; + return const Placeholder(); + }, + ), + ), + ); + + expect(color.value, color.toARGB32()); + }); + testWidgets('CupertinoDynamicColor used in a CupertinoTheme', (WidgetTester tester) async { late CupertinoDynamicColor color; await tester.pumpWidget(