Skip to content

Commit 4e8e9ac

Browse files
authored
Require Dart 3 across the board, use switch expressions (#1344)
1 parent 2185e8b commit 4e8e9ac

File tree

8 files changed

+107
-206
lines changed

8 files changed

+107
-206
lines changed

.github/workflows/dart.yml

Lines changed: 81 additions & 177 deletions
Large diffs are not rendered by default.

checked_yaml/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.4-wip
2+
3+
- Require Dart 3.0
4+
15
## 2.0.3
26

37
- Require Dart 2.19

checked_yaml/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: checked_yaml
2-
version: 2.0.3
2+
version: 2.0.4-wip
33

44
description: >-
55
Generate more helpful exceptions when decoding YAML documents using
@@ -13,7 +13,7 @@ topics:
1313
- codegen
1414

1515
environment:
16-
sdk: '>=2.19.0 <3.0.0'
16+
sdk: ^3.0.0
1717

1818
dependencies:
1919
json_annotation: ^4.3.0

json_annotation/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 4.8.2-wip
2+
3+
- Require Dart 3.0
4+
15
## 4.8.1
26

37
- Require Dart 2.19

json_annotation/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: json_annotation
2-
version: 4.8.1
2+
version: 4.8.2-wip
33
description: >-
44
Classes and helper functions that support JSON code generation via the
55
`json_serializable` package.
@@ -11,7 +11,7 @@ topics:
1111
- codegen
1212

1313
environment:
14-
sdk: '>=2.19.0 <3.0.0'
14+
sdk: ^3.0.0
1515

1616
dependencies:
1717
meta: ^1.4.0

json_serializable/lib/src/utils.dart

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,14 @@ String ifNullOrElse(String test, String ifNull, String ifNotNull) =>
182182
String encodedFieldName(
183183
FieldRename fieldRename,
184184
String declaredName,
185-
) {
186-
switch (fieldRename) {
187-
case FieldRename.none:
188-
return declaredName;
189-
case FieldRename.snake:
190-
return declaredName.snake;
191-
case FieldRename.screamingSnake:
192-
return declaredName.snake.toUpperCase();
193-
case FieldRename.kebab:
194-
return declaredName.kebab;
195-
case FieldRename.pascal:
196-
return declaredName.pascal;
197-
}
198-
}
185+
) =>
186+
switch (fieldRename) {
187+
FieldRename.none => declaredName,
188+
FieldRename.snake => declaredName.snake,
189+
FieldRename.screamingSnake => declaredName.snake.toUpperCase(),
190+
FieldRename.kebab => declaredName.kebab,
191+
FieldRename.pascal => declaredName.pascal
192+
};
199193

200194
/// Return the Dart code presentation for the given [type].
201195
///

json_serializable/test/integration/json_test_common.dart

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,11 @@ class Platform {
5151

5252
const Platform._(this.description);
5353

54-
factory Platform.fromJson(String value) {
55-
switch (value) {
56-
case 'foo':
57-
return foo;
58-
case 'undefined':
59-
return undefined;
60-
default:
61-
throw ArgumentError.value(value, 'value', 'Not a supported value.');
62-
}
63-
}
54+
factory Platform.fromJson(String value) => switch (value) {
55+
'foo' => foo,
56+
'undefined' => undefined,
57+
_ => throw ArgumentError.value(value, 'value', 'Not a supported value.')
58+
};
6459

6560
String toJson() => description;
6661
}

shared_test/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: _json_serial_shared_test
22
publish_to: none
33
environment:
4-
sdk: '>=2.19.0 <3.0.0'
4+
sdk: ^3.0.0
55

66
dependencies:
77
stack_trace: ^1.10.0

0 commit comments

Comments
 (0)