Skip to content

Commit

Permalink
Forward fix CupertinoDynamicColor by adding toARGB32(). (#158145)
Browse files Browse the repository at this point in the history
Unblocks landing flutter/engine#56329.

@jtmcdole monorepo can't come soon enough...
  • Loading branch information
matanlurey authored Nov 6, 2024
1 parent c6dea5e commit 7a6c81a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/flutter/lib/src/cupertino/colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
20 changes: 20 additions & 0 deletions packages/flutter/test/cupertino/colors_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 7a6c81a

Please sign in to comment.