Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Dart 3 across the board, use switch expressions #1344

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
258 changes: 81 additions & 177 deletions .github/workflows/dart.yml

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions checked_yaml/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.4-wip

- Require Dart 3.0

## 2.0.3

- Require Dart 2.19
Expand Down
4 changes: 2 additions & 2 deletions checked_yaml/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: checked_yaml
version: 2.0.3
version: 2.0.4-wip

description: >-
Generate more helpful exceptions when decoding YAML documents using
Expand All @@ -13,7 +13,7 @@ topics:
- codegen

environment:
sdk: '>=2.19.0 <3.0.0'
sdk: ^3.0.0

dependencies:
json_annotation: ^4.3.0
Expand Down
4 changes: 4 additions & 0 deletions json_annotation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.8.2-wip

- Require Dart 3.0

## 4.8.1

- Require Dart 2.19
Expand Down
4 changes: 2 additions & 2 deletions json_annotation/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: json_annotation
version: 4.8.1
version: 4.8.2-wip
description: >-
Classes and helper functions that support JSON code generation via the
`json_serializable` package.
Expand All @@ -11,7 +11,7 @@ topics:
- codegen

environment:
sdk: '>=2.19.0 <3.0.0'
sdk: ^3.0.0

dependencies:
meta: ^1.4.0
Expand Down
22 changes: 8 additions & 14 deletions json_serializable/lib/src/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,14 @@ String ifNullOrElse(String test, String ifNull, String ifNotNull) =>
String encodedFieldName(
FieldRename fieldRename,
String declaredName,
) {
switch (fieldRename) {
case FieldRename.none:
return declaredName;
case FieldRename.snake:
return declaredName.snake;
case FieldRename.screamingSnake:
return declaredName.snake.toUpperCase();
case FieldRename.kebab:
return declaredName.kebab;
case FieldRename.pascal:
return declaredName.pascal;
}
}
) =>
switch (fieldRename) {
FieldRename.none => declaredName,
FieldRename.snake => declaredName.snake,
FieldRename.screamingSnake => declaredName.snake.toUpperCase(),
FieldRename.kebab => declaredName.kebab,
FieldRename.pascal => declaredName.pascal
};

/// Return the Dart code presentation for the given [type].
///
Expand Down
15 changes: 5 additions & 10 deletions json_serializable/test/integration/json_test_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,11 @@ class Platform {

const Platform._(this.description);

factory Platform.fromJson(String value) {
switch (value) {
case 'foo':
return foo;
case 'undefined':
return undefined;
default:
throw ArgumentError.value(value, 'value', 'Not a supported value.');
}
}
factory Platform.fromJson(String value) => switch (value) {
'foo' => foo,
'undefined' => undefined,
_ => throw ArgumentError.value(value, 'value', 'Not a supported value.')
};

String toJson() => description;
}
Expand Down
2 changes: 1 addition & 1 deletion shared_test/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: _json_serial_shared_test
publish_to: none
environment:
sdk: '>=2.19.0 <3.0.0'
sdk: ^3.0.0

dependencies:
stack_trace: ^1.10.0
Expand Down