@@ -10,19 +10,21 @@ part 'platform.g.dart';
10
10
class PubspecPlatform {
11
11
final String description;
12
12
13
- static const PubspecPlatform flutter = const PubspecPlatform ._('flutter' );
13
+ static const PubspecPlatform flutter =
14
+ const PubspecPlatform ._(PlatformFlags .flutter);
14
15
15
- static const PubspecPlatform undefined = const PubspecPlatform ._('undefined' );
16
+ static const PubspecPlatform undefined =
17
+ const PubspecPlatform ._(PlatformFlags .undefined);
16
18
17
19
bool get isFlutter => description == flutter.description;
18
20
19
21
const PubspecPlatform ._(this .description);
20
22
21
23
factory PubspecPlatform .fromJson (String value) {
22
24
switch (value) {
23
- case ' flutter' :
25
+ case PlatformFlags . flutter:
24
26
return flutter;
25
- case ' undefined' :
27
+ case PlatformFlags . undefined:
26
28
return undefined;
27
29
default :
28
30
throw new ArgumentError .value (value, 'value' , 'Not a supported value.' );
@@ -35,11 +37,26 @@ class PubspecPlatform {
35
37
}
36
38
37
39
abstract class PlatformFlags {
38
- /// Denotes a package that references Flutter in `pubspec.yaml` .
40
+ /// Package uses or depends on Flutter.
39
41
static const String flutter = 'flutter' ;
40
42
41
- /// Denotes a library that depends on a native extensions via `dart-ext:`
43
+ /// Package uses or depends on a native extensions via `dart-ext:`
42
44
static const String dartExtension = 'dart-ext' ;
45
+
46
+ /// Package works everywhere.
47
+ static const String everywhere = 'everywhere' ;
48
+
49
+ /// Package's platform is unspecified.
50
+ static const String undefined = 'undefined' ;
51
+
52
+ /// Package's dependencies are in conflict, won't work.
53
+ static const String conflict = 'conflict' ;
54
+
55
+ /// Package is available in server applications.
56
+ static const String server = 'server' ;
57
+
58
+ /// Package is available in web applications.
59
+ static const String web = 'web' ;
43
60
}
44
61
45
62
@JsonSerializable ()
@@ -61,10 +78,10 @@ class PlatformSummary extends Object with _$PlatformSummarySerializerMixin {
61
78
String get description {
62
79
if (pubspec.isFlutter) {
63
80
if (libraries.values.every ((pi) => pi.worksOnFlutter)) {
64
- return ' flutter' ;
81
+ return PlatformFlags . flutter;
65
82
}
66
83
assert (hasConflict);
67
- return ' conflict' ;
84
+ return PlatformFlags . conflict;
68
85
}
69
86
70
87
assert (pubspec == PubspecPlatform .undefined);
@@ -116,25 +133,25 @@ class PlatformInfo extends Object with _$PlatformInfoSerializerMixin {
116
133
117
134
Set <String > get descriptionSet {
118
135
if (worksEverywhere) {
119
- return new Set .from ([' everywhere' ]);
136
+ return new Set .from ([PlatformFlags . everywhere]);
120
137
}
121
138
122
139
var items = < String > [];
123
140
if (worksOnFlutter) {
124
- items.add (' flutter' );
141
+ items.add (PlatformFlags . flutter);
125
142
}
126
143
127
144
if (worksOnServer) {
128
- items.add (' server' );
145
+ items.add (PlatformFlags . server);
129
146
}
130
147
131
148
if (worksOnWeb) {
132
- items.add (' web' );
149
+ items.add (PlatformFlags . web);
133
150
}
134
151
135
152
if (items.isEmpty) {
136
153
assert (hasConflict);
137
- return new Set .from ([' conflict' ]);
154
+ return new Set .from ([PlatformFlags . conflict]);
138
155
}
139
156
140
157
assert (! hasConflict);
0 commit comments