File tree Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Expand file tree Collapse file tree 3 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,12 @@ import 'package:yaml/yaml.dart';
44class Flutter {
55 Flutter (YamlMap flutterMap) {
66 if (flutterMap != null ) {
7- assets = FlutterAssets (safeCast <YamlList >(flutterMap['assets' ]));
8- fonts = FlutterFonts (safeCast <YamlList >(flutterMap['fonts' ]));
7+ if (flutterMap.containsKey ('assets' )) {
8+ assets = FlutterAssets (safeCast <YamlList >(flutterMap['assets' ]));
9+ }
10+ if (flutterMap.containsKey ('fonts' )) {
11+ fonts = FlutterFonts (safeCast <YamlList >(flutterMap['fonts' ]));
12+ }
913 }
1014 }
1115
Original file line number Diff line number Diff line change @@ -8,10 +8,14 @@ class FlutterGen {
88 FlutterGen (YamlMap flutterGenMap) {
99 if (flutterGenMap != null ) {
1010 _output = safeCast <String >(flutterGenMap['output' ]);
11- integrations = FlutterGenIntegrations (
11+ if (flutterGenMap.containsKey ('integrations' )) {
12+ integrations = FlutterGenIntegrations (
1213 safeCast <YamlMap >(flutterGenMap['integrations' ]));
14+ }
1315 _lineLength = safeCast <int >(flutterGenMap['lineLength' ]);
14- colors = FlutterGenColors (safeCast <YamlMap >(flutterGenMap['colors' ]));
16+ if (flutterGenMap.containsKey ('colors' )) {
17+ colors = FlutterGenColors (safeCast <YamlMap >(flutterGenMap['colors' ]));
18+ }
1519 }
1620 }
1721
Original file line number Diff line number Diff line change @@ -146,6 +146,14 @@ void main() {
146146 });
147147
148148 test ('Assets with No inegrations on pubspec.yaml' , () async {
149+ await FlutterGenerator (
150+ File ('test_resources/pubspec_assets_no_integrations.yaml' ))
151+ .build ();
152+ expect (
153+ File ('test_resources/lib/gen/assets.gen.dart' ).readAsStringSync (),
154+ isNotEmpty,
155+ );
156+
149157 final pubspec = File ('test_resources/pubspec_assets_no_integrations.yaml' );
150158 final config = await Config (pubspec).load ();
151159 final formatter = DartFormatter (pageWidth: config.flutterGen.lineLength);
You can’t perform that action at this time.
0 commit comments