1
+ import 'dart:ui' ;
2
+
1
3
import 'package:dart_eval/dart_eval_bridge.dart' ;
2
4
import 'package:flutter/painting.dart' ;
3
5
@@ -14,6 +16,20 @@ class $Color implements Color, $Instance {
14
16
BridgeParameter ('value' ,
15
17
BridgeTypeAnnotation (BridgeTypeRef (CoreTypes .int )), false )
16
18
])),
19
+ 'from' : BridgeConstructorDef (BridgeFunctionDef (
20
+ returns: BridgeTypeAnnotation ($type),
21
+ namedParams: [
22
+ BridgeParameter ('alpha' ,
23
+ BridgeTypeAnnotation (BridgeTypeRef (CoreTypes .int )), false ),
24
+ BridgeParameter ('red' ,
25
+ BridgeTypeAnnotation (BridgeTypeRef (CoreTypes .int )), false ),
26
+ BridgeParameter ('green' ,
27
+ BridgeTypeAnnotation (BridgeTypeRef (CoreTypes .int )), false ),
28
+ BridgeParameter ('blue' ,
29
+ BridgeTypeAnnotation (BridgeTypeRef (CoreTypes .int )), false ),
30
+ BridgeParameter (
31
+ 'colorSpace' , BridgeTypeAnnotation ($ColorSpace .$type), true )
32
+ ])),
17
33
'fromARGB' : BridgeConstructorDef (
18
34
BridgeFunctionDef (returns: BridgeTypeAnnotation ($type), params: [
19
35
BridgeParameter (
@@ -37,6 +53,17 @@ class $Color implements Color, $Instance {
37
53
'o' , BridgeTypeAnnotation (BridgeTypeRef (CoreTypes .int )), false )
38
54
]))
39
55
},
56
+ fields: {
57
+ 'a' : BridgeFieldDef (
58
+ BridgeTypeAnnotation (BridgeTypeRef (CoreTypes .double ))),
59
+ 'r' : BridgeFieldDef (
60
+ BridgeTypeAnnotation (BridgeTypeRef (CoreTypes .double ))),
61
+ 'g' : BridgeFieldDef (
62
+ BridgeTypeAnnotation (BridgeTypeRef (CoreTypes .double ))),
63
+ 'b' : BridgeFieldDef (
64
+ BridgeTypeAnnotation (BridgeTypeRef (CoreTypes .double ))),
65
+ 'colorSpace' : BridgeFieldDef (BridgeTypeAnnotation ($ColorSpace .$type))
66
+ },
40
67
wrap: true );
41
68
42
69
/// Wrap a [Color] in an [$Color]
@@ -65,6 +92,21 @@ class $Color implements Color, $Instance {
65
92
throw UnimplementedError ();
66
93
}
67
94
95
+ @override
96
+ double get a => $value.a;
97
+
98
+ @override
99
+ double get r => $value.r;
100
+
101
+ @override
102
+ double get g => $value.g;
103
+
104
+ @override
105
+ double get b => $value.b;
106
+
107
+ @override
108
+ ColorSpace get colorSpace => $value.colorSpace;
109
+
68
110
@override
69
111
int get alpha => $value.alpha;
70
112
@@ -100,6 +142,21 @@ class $Color implements Color, $Instance {
100
142
101
143
@override
102
144
Color withRed (int r) => $value.withRed (r);
145
+
146
+ @override
147
+ Color withValues (
148
+ {double ? alpha,
149
+ double ? red,
150
+ double ? green,
151
+ double ? blue,
152
+ ColorSpace ? colorSpace}) =>
153
+ $value.withValues (
154
+ alpha: alpha,
155
+ red: red,
156
+ green: green,
157
+ blue: blue,
158
+ colorSpace: colorSpace,
159
+ );
103
160
}
104
161
105
162
/// dart_eval wrapper for [Clip]
@@ -144,3 +201,35 @@ class $Clip implements $Instance {
144
201
throw UnimplementedError ();
145
202
}
146
203
}
204
+
205
+ class $ColorSpace implements $Instance {
206
+ static const $type = BridgeTypeRef (BridgeTypeSpec ('dart:ui' , 'ColorSpace' ));
207
+
208
+ static const $declaration = BridgeEnumDef ($type,
209
+ values: ['sRGB' , 'extendedSRGB' , 'displayP3' ], fields: {});
210
+
211
+ static final $values = ColorSpace .values
212
+ .asNameMap ()
213
+ .map ((key, value) => MapEntry (key, $ColorSpace .wrap (value)));
214
+
215
+ const $ColorSpace .wrap (this .$value);
216
+
217
+ @override
218
+ final ColorSpace $value;
219
+
220
+ @override
221
+ ColorSpace get $reified => $value;
222
+
223
+ @override
224
+ $Value ? $getProperty (Runtime runtime, String identifier) {
225
+ throw UnimplementedError ();
226
+ }
227
+
228
+ @override
229
+ int $getRuntimeType (Runtime runtime) => runtime.lookupType ($type.spec! );
230
+
231
+ @override
232
+ void $setProperty (Runtime runtime, String identifier, $Value value) {
233
+ throw UnimplementedError ();
234
+ }
235
+ }
0 commit comments