Unverified Commit 98b9f314 authored by LongCatIsLooong's avatar LongCatIsLooong Committed by GitHub

make CupertinoDynamicColor const constructible (#39430)

* make CupertinoDynamicColor const constructible

* review
parent f6d3f9ad
...@@ -11,6 +11,17 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -11,6 +11,17 @@ import 'package:flutter_test/flutter_test.dart';
import '../rendering/mock_canvas.dart'; import '../rendering/mock_canvas.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
const CupertinoDynamicColor _kSystemFill = CupertinoDynamicColor(
color: Color.fromARGB(51, 120, 120, 128),
darkColor: Color.fromARGB(91, 120, 120, 128),
highContrastColor: Color.fromARGB(71, 120, 120, 128),
darkHighContrastColor: Color.fromARGB(112, 120, 120, 128),
elevatedColor: Color.fromARGB(51, 120, 120, 128),
darkElevatedColor: Color.fromARGB(91, 120, 120, 128),
highContrastElevatedColor: Color.fromARGB(71, 120, 120, 128),
darkHighContrastElevatedColor: Color.fromARGB(112, 120, 120, 128),
);
void main() { void main() {
Future<void> _dragSlider(WidgetTester tester, Key sliderKey) { Future<void> _dragSlider(WidgetTester tester, Key sliderKey) {
...@@ -441,15 +452,15 @@ void main() { ...@@ -441,15 +452,15 @@ void main() {
}); });
testWidgets('Themes can be overridden by dynamic colors', (WidgetTester tester) async { testWidgets('Themes can be overridden by dynamic colors', (WidgetTester tester) async {
final CupertinoDynamicColor activeColor = CupertinoDynamicColor( const CupertinoDynamicColor activeColor = CupertinoDynamicColor(
color: const Color(0x00000001), color: Color(0x00000001),
darkColor: const Color(0x00000002), darkColor: Color(0x00000002),
elevatedColor: const Color(0x00000003), elevatedColor: Color(0x00000003),
highContrastColor: const Color(0x00000004), highContrastColor: Color(0x00000004),
darkElevatedColor: const Color(0x00000005), darkElevatedColor: Color(0x00000005),
darkHighContrastColor: const Color(0x00000006), darkHighContrastColor: Color(0x00000006),
highContrastElevatedColor: const Color(0x00000007), highContrastElevatedColor: Color(0x00000007),
darkHighContrastElevatedColor: const Color(0x00000008), darkHighContrastElevatedColor: Color(0x00000008),
); );
Widget withTraits(Brightness brightness, CupertinoUserInterfaceLevelData level, bool highContrast) { Widget withTraits(Brightness brightness, CupertinoUserInterfaceLevelData level, bool highContrast) {
...@@ -512,12 +523,12 @@ void main() { ...@@ -512,12 +523,12 @@ void main() {
expect( expect(
find.byType(CupertinoSlider), find.byType(CupertinoSlider),
paints..rrect(color: CupertinoSystemColors.fallbackValues.systemFill.color), paints..rrect(color: _kSystemFill.color),
); );
expect( expect(
find.byType(CupertinoSlider), find.byType(CupertinoSlider),
isNot(paints..rrect(color: CupertinoSystemColors.fallbackValues.systemFill.darkColor)), isNot(paints..rrect(color: _kSystemFill.darkColor)),
); );
await tester.pumpWidget( await tester.pumpWidget(
...@@ -535,12 +546,12 @@ void main() { ...@@ -535,12 +546,12 @@ void main() {
expect( expect(
find.byType(CupertinoSlider), find.byType(CupertinoSlider),
paints..rrect(color: CupertinoSystemColors.fallbackValues.systemFill.darkColor), paints..rrect(color: _kSystemFill.darkColor),
); );
expect( expect(
find.byType(CupertinoSlider), find.byType(CupertinoSlider),
isNot(paints..rrect(color: CupertinoSystemColors.fallbackValues.systemFill.color)), isNot(paints..rrect(color: _kSystemFill.color)),
); );
}); });
} }
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