Skip to content

Commit 01a9c5d

Browse files
authored
[native_assets_cli] Make nullable fields required in syntax (#2121)
1 parent ce2e40b commit 01a9c5d

File tree

5 files changed

+39
-40
lines changed

5 files changed

+39
-40
lines changed

pkgs/json_syntax_generator/lib/src/generator/normal_class_generator.dart

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,14 @@ class ClassGenerator {
3939
final property = superClassProperty ?? thisClassProperty!;
4040
if (superClassProperty != null) {
4141
if (identifyingSubtype == null) {
42-
constructorParams.add(
43-
'${property.isRequired ? 'required ' : ''}super.${property.name}',
44-
);
42+
constructorParams.add('required super.${property.name}');
4543
} else {
4644
superParams.add("type: '$identifyingSubtype'");
4745
}
4846
} else {
4947
final dartType = property.type;
50-
constructorParams.add(
51-
'${property.isRequired ? 'required ' : ''}$dartType ${property.name}',
52-
);
53-
setupParams.add(
54-
'${property.isRequired ? 'required' : ''} $dartType ${property.name}',
55-
);
48+
constructorParams.add('required $dartType ${property.name}');
49+
setupParams.add('required $dartType ${property.name}');
5650
if (property.setterPrivate) {
5751
constructorSetterCalls.add('_${property.name} = ${property.name};');
5852
} else {

pkgs/native_assets_cli/lib/src/code_assets/syntax.g.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class Asset {
9494

9595
Asset.fromJson(this.json, {this.path = const []});
9696

97-
Asset({String? type}) : json = {}, path = const [] {
97+
Asset({required String? type}) : json = {}, path = const [] {
9898
_type = type;
9999
json.sortOnKey();
100100
}
@@ -118,7 +118,7 @@ class NativeCodeAsset extends Asset {
118118

119119
NativeCodeAsset({
120120
required Architecture architecture,
121-
Uri? file,
121+
required Uri? file,
122122
required String id,
123123
required LinkMode linkMode,
124124
required OS os,
@@ -135,7 +135,7 @@ class NativeCodeAsset extends Asset {
135135
/// [Asset].
136136
void setup({
137137
required Architecture architecture,
138-
Uri? file,
138+
required Uri? file,
139139
required String id,
140140
required LinkMode linkMode,
141141
required OS os,
@@ -237,10 +237,10 @@ class CCompilerConfig {
237237
CCompilerConfig({
238238
required Uri ar,
239239
required Uri cc,
240-
Uri? envScript,
241-
List<String>? envScriptArguments,
240+
required Uri? envScript,
241+
required List<String>? envScriptArguments,
242242
required Uri ld,
243-
Windows? windows,
243+
required Windows? windows,
244244
}) : json = {},
245245
path = const [] {
246246
_ar = ar;
@@ -335,7 +335,7 @@ class Windows {
335335

336336
Windows.fromJson(this.json, {this.path = const []});
337337

338-
Windows({DeveloperCommandPrompt? developerCommandPrompt})
338+
Windows({required DeveloperCommandPrompt? developerCommandPrompt})
339339
: json = {},
340340
path = const [] {
341341
_developerCommandPrompt = developerCommandPrompt;
@@ -420,11 +420,11 @@ class CodeConfig {
420420
CodeConfig.fromJson(this.json, {this.path = const []});
421421

422422
CodeConfig({
423-
AndroidCodeConfig? android,
424-
CCompilerConfig? cCompiler,
425-
IOSCodeConfig? iOS,
423+
required AndroidCodeConfig? android,
424+
required CCompilerConfig? cCompiler,
425+
required IOSCodeConfig? iOS,
426426
required LinkModePreference linkModePreference,
427-
MacOSCodeConfig? macOS,
427+
required MacOSCodeConfig? macOS,
428428
required Architecture targetArchitecture,
429429
required OS targetOs,
430430
}) : json = {},
@@ -569,7 +569,7 @@ class Config {
569569

570570
Config.fromJson(this.json, {this.path = const []});
571571

572-
Config({CodeConfig? code}) : json = {}, path = const [] {
572+
Config({required CodeConfig? code}) : json = {}, path = const [] {
573573
this.code = code;
574574
json.sortOnKey();
575575
}

pkgs/native_assets_cli/lib/src/config.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ sealed class HookOutputBuilder {
298298
final _syntax = syntax.HookOutput(
299299
timestamp: DateTime.now().roundDownToSeconds().toString(),
300300
version: latestVersion.toString(),
301+
assets: null,
302+
dependencies: null,
301303
);
302304

303305
Map<String, Object?> get json => _syntax.json;

pkgs/native_assets_cli/lib/src/data_assets/syntax.g.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Asset {
1919

2020
Asset.fromJson(this.json, {this.path = const []});
2121

22-
Asset({String? type}) : json = {}, path = const [] {
22+
Asset({required String? type}) : json = {}, path = const [] {
2323
_type = type;
2424
json.sortOnKey();
2525
}

pkgs/native_assets_cli/lib/src/hook/syntax.g.dart

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ class BuildInput extends HookInput {
7878

7979
BuildInput({
8080
required super.config,
81-
Map<String, Map<String, Object?>>? dependencyMetadata,
81+
required Map<String, Map<String, Object?>>? dependencyMetadata,
8282
required super.outDir,
8383
required super.outDirShared,
84-
super.outFile,
84+
required super.outFile,
8585
required super.packageName,
8686
required super.packageRoot,
8787
required super.version,
@@ -92,7 +92,7 @@ class BuildInput extends HookInput {
9292

9393
/// Setup all fields for [BuildInput] that are not in
9494
/// [HookInput].
95-
void setup({Map<String, Map<String, Object?>>? dependencyMetadata}) {
95+
void setup({required Map<String, Map<String, Object?>>? dependencyMetadata}) {
9696
_dependencyMetadata = dependencyMetadata;
9797
json.sortOnKey();
9898
}
@@ -128,10 +128,10 @@ class BuildOutput extends HookOutput {
128128
BuildOutput.fromJson(super.json, {super.path}) : super.fromJson();
129129

130130
BuildOutput({
131-
super.assets,
132-
Map<String, List<Asset>>? assetsForLinking,
133-
super.dependencies,
134-
Map<String, Object?>? metadata,
131+
required super.assets,
132+
required Map<String, List<Asset>>? assetsForLinking,
133+
required super.dependencies,
134+
required Map<String, Object?>? metadata,
135135
required super.timestamp,
136136
required super.version,
137137
}) : super() {
@@ -143,8 +143,8 @@ class BuildOutput extends HookOutput {
143143
/// Setup all fields for [BuildOutput] that are not in
144144
/// [HookOutput].
145145
void setup({
146-
Map<String, List<Asset>>? assetsForLinking,
147-
Map<String, Object?>? metadata,
146+
required Map<String, List<Asset>>? assetsForLinking,
147+
required Map<String, Object?>? metadata,
148148
}) {
149149
this.assetsForLinking = assetsForLinking;
150150
this.metadata = metadata;
@@ -262,7 +262,7 @@ class HookInput {
262262
required Config config,
263263
required Uri outDir,
264264
required Uri outDirShared,
265-
Uri? outFile,
265+
required Uri? outFile,
266266
required String packageName,
267267
required Uri packageRoot,
268268
required String version,
@@ -376,8 +376,8 @@ class HookOutput {
376376
HookOutput.fromJson(this.json, {this.path = const []});
377377

378378
HookOutput({
379-
List<Asset>? assets,
380-
List<Uri>? dependencies,
379+
required List<Asset>? assets,
380+
required List<Uri>? dependencies,
381381
required String timestamp,
382382
required String version,
383383
}) : json = {},
@@ -467,14 +467,14 @@ class LinkInput extends HookInput {
467467
LinkInput.fromJson(super.json, {super.path}) : super.fromJson();
468468

469469
LinkInput({
470-
List<Asset>? assets,
470+
required List<Asset>? assets,
471471
required super.config,
472472
required super.outDir,
473473
required super.outDirShared,
474-
super.outFile,
474+
required super.outFile,
475475
required super.packageName,
476476
required super.packageRoot,
477-
Uri? resourceIdentifiers,
477+
required Uri? resourceIdentifiers,
478478
required super.version,
479479
}) : super() {
480480
_assets = assets;
@@ -484,7 +484,10 @@ class LinkInput extends HookInput {
484484

485485
/// Setup all fields for [LinkInput] that are not in
486486
/// [HookInput].
487-
void setup({List<Asset>? assets, Uri? resourceIdentifiers}) {
487+
void setup({
488+
required List<Asset>? assets,
489+
required Uri? resourceIdentifiers,
490+
}) {
488491
_assets = assets;
489492
_resourceIdentifiers = resourceIdentifiers;
490493
json.sortOnKey();
@@ -548,8 +551,8 @@ class LinkOutput extends HookOutput {
548551
LinkOutput.fromJson(super.json, {super.path}) : super.fromJson();
549552

550553
LinkOutput({
551-
super.assets,
552-
super.dependencies,
554+
required super.assets,
555+
required super.dependencies,
553556
required super.timestamp,
554557
required super.version,
555558
}) : super();

0 commit comments

Comments
 (0)