Skip to content

Commit 010cae8

Browse files
committed
fix null check build error
1 parent 809be17 commit 010cae8

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

packages/runner/lib/flutter_gen_runner.dart

+26-26
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,39 @@ class FlutterGenBuilder extends Builder {
3434

3535
@override
3636
Future<void> build(BuildStep buildStep) async {
37-
if (_config == null) {
38-
return;
39-
}
40-
final state = await _createState(_config, buildStep);
41-
if (state.shouldSkipGenerate(_currentState)) {
42-
return;
37+
if (_config case final config?) {
38+
final state = await _createState(config, buildStep);
39+
if (state.shouldSkipGenerate(_currentState)) {
40+
return;
41+
}
42+
_currentState = state;
43+
44+
await generator.build(
45+
config: config,
46+
writer: (contents, path) {
47+
buildStep.writeAsString(_output(buildStep, path), contents);
48+
},
49+
);
4350
}
44-
_currentState = state;
45-
46-
await generator.build(
47-
config: _config,
48-
writer: (contents, path) {
49-
buildStep.writeAsString(_output(buildStep, path), contents);
50-
},
51-
);
5251
}
5352

5453
@override
5554
Map<String, List<String>> get buildExtensions {
56-
if (_config == null) {
55+
if (_config case final config?) {
56+
final output = config.pubspec.flutterGen.output;
57+
return {
58+
r'$package$': [
59+
for (final name in [
60+
generator.assetsName,
61+
generator.colorsName,
62+
generator.fontsName,
63+
])
64+
join(output, name),
65+
],
66+
};
67+
} else {
5768
return {};
5869
}
59-
final output = _config.pubspec.flutterGen.output;
60-
return {
61-
r'$package$': [
62-
for (final name in [
63-
generator.assetsName,
64-
generator.colorsName,
65-
generator.fontsName,
66-
])
67-
join(output, name),
68-
],
69-
};
7070
}
7171

7272
Future<_FlutterGenBuilderState> _createState(

0 commit comments

Comments
 (0)