Skip to content

Commit 9fb78fc

Browse files
authored
chore: update json_serializable and add to example code (#157)
* chore: update json_serializable and add to example code * chore: upgrade dependencies
1 parent c52e451 commit 9fb78fc

File tree

9 files changed

+141
-101
lines changed

9 files changed

+141
-101
lines changed
Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
// ignore_for_file: directives_ordering
22
import 'package:build_runner_core/build_runner_core.dart' as _i1;
33
import 'package:flutter_gen_runner/flutter_gen_runner.dart' as _i2;
4-
import 'dart:isolate' as _i3;
5-
import 'package:build_runner/build_runner.dart' as _i4;
6-
import 'dart:io' as _i5;
4+
import 'package:json_serializable/builder.dart' as _i3;
5+
import 'package:source_gen/builder.dart' as _i4;
6+
import 'dart:isolate' as _i5;
7+
import 'package:build_runner/build_runner.dart' as _i6;
8+
import 'dart:io' as _i7;
79

810
final _builders = <_i1.BuilderApplication>[
911
_i1.apply(r'flutter_gen_runner:flutter_gen_runner', [_i2.build],
1012
_i1.toDependentsOf(r'flutter_gen_runner'),
11-
hideOutput: false)
13+
hideOutput: false),
14+
_i1.apply(r'json_serializable:json_serializable', [_i3.jsonSerializable],
15+
_i1.toDependentsOf(r'json_serializable'),
16+
hideOutput: true,
17+
appliesBuilders: const [r'source_gen:combining_builder']),
18+
_i1.apply(r'source_gen:combining_builder', [_i4.combiningBuilder],
19+
_i1.toNoneByDefault(),
20+
hideOutput: false, appliesBuilders: const [r'source_gen:part_cleanup']),
21+
_i1.applyPostProcess(r'source_gen:part_cleanup', _i4.partCleanup)
1222
];
13-
void main(List<String> args, [_i3.SendPort? sendPort]) async {
14-
var result = await _i4.run(args, _builders);
23+
void main(List<String> args, [_i5.SendPort? sendPort]) async {
24+
var result = await _i6.run(args, _builders);
1525
sendPort?.send(result);
16-
_i5.exitCode = result;
26+
_i7.exitCode = result;
1727
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import 'package:json_annotation/json_annotation.dart';
2+
3+
part 'json_serializable_sample.g.dart';
4+
5+
@JsonSerializable()
6+
class Person {
7+
final String firstName, lastName;
8+
final DateTime? dateOfBirth;
9+
10+
Person({required this.firstName, required this.lastName, this.dateOfBirth});
11+
factory Person.fromJson(Map<String, dynamic> json) => _$PersonFromJson(json);
12+
Map<String, dynamic> toJson() => _$PersonToJson(this);
13+
}

example/lib/json_serializable_sample.g.dart

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/pubspec.lock

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ packages:
77
name: _fe_analyzer_shared
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "26.0.0"
10+
version: "30.0.0"
1111
analyzer:
1212
dependency: transitive
1313
description:
1414
name: analyzer
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "2.3.0"
17+
version: "2.7.0"
1818
args:
1919
dependency: transitive
2020
description:
@@ -42,7 +42,7 @@ packages:
4242
name: build
4343
url: "https://pub.dartlang.org"
4444
source: hosted
45-
version: "2.1.0"
45+
version: "2.1.1"
4646
build_config:
4747
dependency: transitive
4848
description:
@@ -56,7 +56,7 @@ packages:
5656
name: build_daemon
5757
url: "https://pub.dartlang.org"
5858
source: hosted
59-
version: "3.0.0"
59+
version: "3.0.1"
6060
build_resolvers:
6161
dependency: transitive
6262
description:
@@ -70,14 +70,14 @@ packages:
7070
name: build_runner
7171
url: "https://pub.dartlang.org"
7272
source: hosted
73-
version: "2.1.2"
73+
version: "2.1.4"
7474
build_runner_core:
7575
dependency: transitive
7676
description:
7777
name: build_runner_core
7878
url: "https://pub.dartlang.org"
7979
source: hosted
80-
version: "7.1.0"
80+
version: "7.2.2"
8181
built_collection:
8282
dependency: transitive
8383
description:
@@ -91,7 +91,7 @@ packages:
9191
name: built_value
9292
url: "https://pub.dartlang.org"
9393
source: hosted
94-
version: "8.1.2"
94+
version: "8.1.3"
9595
characters:
9696
dependency: transitive
9797
description:
@@ -119,7 +119,7 @@ packages:
119119
name: cli_util
120120
url: "https://pub.dartlang.org"
121121
source: hosted
122-
version: "0.3.3"
122+
version: "0.3.5"
123123
clock:
124124
dependency: transitive
125125
description:
@@ -175,7 +175,7 @@ packages:
175175
name: dartx
176176
url: "https://pub.dartlang.org"
177177
source: hosted
178-
version: "0.7.1"
178+
version: "0.8.0"
179179
fake_async:
180180
dependency: transitive
181181
description:
@@ -255,7 +255,7 @@ packages:
255255
name: glob
256256
url: "https://pub.dartlang.org"
257257
source: hosted
258-
version: "2.0.1"
258+
version: "2.0.2"
259259
graphs:
260260
dependency: transitive
261261
description:
@@ -299,12 +299,19 @@ packages:
299299
source: hosted
300300
version: "0.6.3"
301301
json_annotation:
302-
dependency: transitive
302+
dependency: "direct main"
303303
description:
304304
name: json_annotation
305305
url: "https://pub.dartlang.org"
306306
source: hosted
307-
version: "4.1.0"
307+
version: "4.3.0"
308+
json_serializable:
309+
dependency: "direct dev"
310+
description:
311+
name: json_serializable
312+
url: "https://pub.dartlang.org"
313+
source: hosted
314+
version: "6.0.1"
308315
lints:
309316
dependency: transitive
310317
description:
@@ -339,7 +346,7 @@ packages:
339346
name: mime
340347
url: "https://pub.dartlang.org"
341348
source: hosted
342-
version: "1.0.0"
349+
version: "1.0.1"
343350
package_config:
344351
dependency: transitive
345352
description:
@@ -360,28 +367,21 @@ packages:
360367
name: path_drawing
361368
url: "https://pub.dartlang.org"
362369
source: hosted
363-
version: "0.5.1"
370+
version: "0.5.1+1"
364371
path_parsing:
365372
dependency: transitive
366373
description:
367374
name: path_parsing
368375
url: "https://pub.dartlang.org"
369376
source: hosted
370377
version: "0.2.1"
371-
pedantic:
372-
dependency: transitive
373-
description:
374-
name: pedantic
375-
url: "https://pub.dartlang.org"
376-
source: hosted
377-
version: "1.11.1"
378378
petitparser:
379379
dependency: transitive
380380
description:
381381
name: petitparser
382382
url: "https://pub.dartlang.org"
383383
source: hosted
384-
version: "4.3.0"
384+
version: "4.4.0"
385385
pool:
386386
dependency: transitive
387387
description:
@@ -409,7 +409,7 @@ packages:
409409
name: rive
410410
url: "https://pub.dartlang.org"
411411
source: hosted
412-
version: "0.7.32"
412+
version: "0.7.33"
413413
shelf:
414414
dependency: transitive
415415
description:
@@ -429,6 +429,20 @@ packages:
429429
description: flutter
430430
source: sdk
431431
version: "0.0.99"
432+
source_gen:
433+
dependency: transitive
434+
description:
435+
name: source_gen
436+
url: "https://pub.dartlang.org"
437+
source: hosted
438+
version: "1.1.1"
439+
source_helper:
440+
dependency: transitive
441+
description:
442+
name: source_helper
443+
url: "https://pub.dartlang.org"
444+
source: hosted
445+
version: "1.3.0"
432446
source_span:
433447
dependency: transitive
434448
description:
@@ -512,7 +526,7 @@ packages:
512526
name: watcher
513527
url: "https://pub.dartlang.org"
514528
source: hosted
515-
version: "1.0.0"
529+
version: "1.0.1"
516530
web_socket_channel:
517531
dependency: transitive
518532
description:
@@ -526,7 +540,7 @@ packages:
526540
name: xml
527541
url: "https://pub.dartlang.org"
528542
source: hosted
529-
version: "5.3.0"
543+
version: "5.3.1"
530544
yaml:
531545
dependency: transitive
532546
description:

example/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ dependencies:
1717
flare_flutter: ^3.0.2
1818
rive: ^0.7.22
1919

20+
json_annotation: ^4.3.0
21+
2022
dev_dependencies:
2123
flutter_test:
2224
sdk: flutter
@@ -25,6 +27,7 @@ dev_dependencies:
2527
path: ../packages/runner
2628

2729
flutter_lints: '>=1.0.4 <2.0.0'
30+
json_serializable: '^6.0.1'
2831

2932
flutter_gen:
3033
output: lib/gen/ # Optional (default: lib/gen/)

packages/command/pubspec.lock

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ packages:
77
name: _fe_analyzer_shared
88
url: "https://pub.dartlang.org"
99
source: hosted
10-
version: "26.0.0"
10+
version: "30.0.0"
1111
analyzer:
1212
dependency: transitive
1313
description:
1414
name: analyzer
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "2.3.0"
17+
version: "2.7.0"
1818
args:
1919
dependency: "direct main"
2020
description:
@@ -49,7 +49,7 @@ packages:
4949
name: cli_util
5050
url: "https://pub.dartlang.org"
5151
source: hosted
52-
version: "0.3.3"
52+
version: "0.3.5"
5353
collection:
5454
dependency: transitive
5555
description:
@@ -91,7 +91,7 @@ packages:
9191
name: dartx
9292
url: "https://pub.dartlang.org"
9393
source: hosted
94-
version: "0.7.1"
94+
version: "0.8.0"
9595
file:
9696
dependency: transitive
9797
description:
@@ -119,14 +119,14 @@ packages:
119119
name: glob
120120
url: "https://pub.dartlang.org"
121121
source: hosted
122-
version: "2.0.1"
122+
version: "2.0.2"
123123
json_annotation:
124124
dependency: transitive
125125
description:
126126
name: json_annotation
127127
url: "https://pub.dartlang.org"
128128
source: hosted
129-
version: "4.1.0"
129+
version: "4.3.0"
130130
lints:
131131
dependency: transitive
132132
description:
@@ -147,7 +147,7 @@ packages:
147147
name: mime
148148
url: "https://pub.dartlang.org"
149149
source: hosted
150-
version: "1.0.0"
150+
version: "1.0.1"
151151
package_config:
152152
dependency: transitive
153153
description:
@@ -162,20 +162,13 @@ packages:
162162
url: "https://pub.dartlang.org"
163163
source: hosted
164164
version: "1.8.0"
165-
pedantic:
166-
dependency: transitive
167-
description:
168-
name: pedantic
169-
url: "https://pub.dartlang.org"
170-
source: hosted
171-
version: "1.11.1"
172165
petitparser:
173166
dependency: transitive
174167
description:
175168
name: petitparser
176169
url: "https://pub.dartlang.org"
177170
source: hosted
178-
version: "4.3.0"
171+
version: "4.4.0"
179172
pub_semver:
180173
dependency: transitive
181174
description:
@@ -224,14 +217,14 @@ packages:
224217
name: watcher
225218
url: "https://pub.dartlang.org"
226219
source: hosted
227-
version: "1.0.0"
220+
version: "1.0.1"
228221
xml:
229222
dependency: transitive
230223
description:
231224
name: xml
232225
url: "https://pub.dartlang.org"
233226
source: hosted
234-
version: "5.3.0"
227+
version: "5.3.1"
235228
yaml:
236229
dependency: transitive
237230
description:

0 commit comments

Comments
 (0)