File tree 2 files changed +16
-3
lines changed
2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -8,4 +8,6 @@ import 'json_serializable.dart';
8
8
9
9
Builder jsonSerializable (BuilderOptions options) => jsonPartBuilder (
10
10
header: options.config['header' ] as String ,
11
- useWrappers: options.config['use_wrappers' ] as bool ?? false );
11
+ useWrappers: options.config['use_wrappers' ] as bool ?? false ,
12
+ requireLibraryDirective:
13
+ options.config['require_library_directive' ] as bool ?? true );
Original file line number Diff line number Diff line change @@ -20,6 +20,13 @@ import 'json_serializable_generator.dart';
20
20
/// increase the code size, but it may improve runtime performance, especially
21
21
/// for large object graphs.
22
22
///
23
+ /// May set [requireLibraryDirective] to `false` in order to opt-in to
24
+ /// supporting a Dart v2 feature of `part of` being usable without an explicit
25
+ /// `library` directive. Developers should restrict their `pubspec` accordingly:
26
+ /// ```yaml
27
+ /// sdk: '>=2.0.0-dev <2.0.0'
28
+ /// ```
29
+ ///
23
30
/// Usage:
24
31
///
25
32
/// ```dart
@@ -34,10 +41,14 @@ import 'json_serializable_generator.dart';
34
41
/// `json_serializable` .
35
42
///
36
43
/// [example] : https://github.com/dart-lang/json_serializable/tree/master/example
37
- Builder jsonPartBuilder ({String header, bool useWrappers: false }) {
44
+ Builder jsonPartBuilder (
45
+ {String header,
46
+ bool useWrappers: false ,
47
+ bool requireLibraryDirective: true }) {
38
48
useWrappers ?? = false ;
49
+ requireLibraryDirective ?? = true ;
39
50
return new PartBuilder ([
40
51
new JsonSerializableGenerator (useWrappers: useWrappers),
41
52
const JsonLiteralGenerator ()
42
- ], header: header);
53
+ ], header: header, requireLibraryDirective : requireLibraryDirective );
43
54
}
You can’t perform that action at this time.
0 commit comments