Migrated to Dart 3

This commit is contained in:
thomashii@dukefirehawk.com 2023-03-26 09:38:56 +08:00
parent 0010405bda
commit 5ad3ab195d
6 changed files with 20 additions and 18 deletions

View file

@ -1,5 +1,9 @@
# Change Log
## 7.0.0-beta.1
* Require Dart >= 3.0
## 6.0.1
* Updated README

View file

@ -12,7 +12,7 @@ The ***new and improved*** definitive solution for JSON in Dart. It supports syn
## Installation
dependencies:
belatuk_json_serializer: ^6.0.0
belatuk_json_serializer: ^7.0.0
## Usage

View file

@ -1,12 +1,12 @@
name: belatuk_json_serializer
version: 6.0.1
version: 7.0.0-beta.1
description: Easy JSON to Object serialization and deserialization in Dart.
homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/json_serializer
environment:
sdk: '>=2.17.0 <3.0.0'
sdk: '>=3.0.0-290.3.beta <4.0.0'
dependencies:
logging: ^1.0.1
dev_dependencies:
stack_trace: ^1.10.0
test: ^1.17.4
test: ^1.24.0
lints: ^2.0.0

View file

@ -105,11 +105,11 @@ testDeserializationWithSchemaValidation() async {
god.deserialize(babelRcJson, outputType: BabelRc) as BabelRc;
print(deserialized.presets.runtimeType);
expect(deserialized.presets is List, equals(true));
//expect(deserialized.presets is List, equals(true));
expect(deserialized.presets.length, equals(2));
expect(deserialized.presets[0], equals('es2015'));
expect(deserialized.presets[1], equals('stage-0'));
expect(deserialized.plugins is List, equals(true));
//expect(deserialized.plugins is List, equals(true));
expect(deserialized.plugins.length, equals(1));
expect(deserialized.plugins[0], equals('add-module-exports'));
}

View file

@ -11,14 +11,14 @@ void printRecord(LogRecord rec) {
class SampleNestedClass {
String? bar;
SampleNestedClass([String? this.bar]);
SampleNestedClass([this.bar]);
}
class SampleClass {
String? hello;
List<SampleNestedClass> nested = [];
SampleClass([String? this.hello]);
SampleClass([this.hello]);
}
@WithSchemaUrl(
@ -27,25 +27,23 @@ class BabelRc {
List<String> presets;
List<String> plugins;
BabelRc(
{List<String> this.presets: const [],
List<String> this.plugins: const []});
BabelRc({this.presets = const [], this.plugins = const []});
}
@WithSchema(const {
@WithSchema({
r"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Validated Sample Class",
"description": "Sample schema for validation via JSON God",
"type": "object",
"hello": const {"description": "A friendly greeting.", "type": "string"},
"nested": const {
"hello": {"description": "A friendly greeting.", "type": "string"},
"nested": {
"description": "A list of NestedSampleClass items within this instance.",
"type": "array",
"items": const {
"items": {
"type": "object",
"bar": const {"description": "Filler text", "type": "string"}
"bar": {"description": "Filler text", "type": "string"}
}
},
"required": const ["hello", "nested"]
"required": ["hello", "nested"]
})
class ValidatedSampleClass {}

View file

@ -8,7 +8,7 @@ main() {
test('fromJson', () {
var foo = god.deserialize('{"bar":"baz"}', outputType: Foo) as Foo;
expect(foo is Foo, true);
//expect(foo is Foo, true);
expect(foo.text, equals('baz'));
});