Skip to content

Commit

Permalink
Merge pull request #22 from nekocode/patch-1
Browse files Browse the repository at this point in the history
Fix #21
  • Loading branch information
wasabeef authored Sep 8, 2020
2 parents f40ab36 + 2552aca commit 905324e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/src/settings/flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import 'package:yaml/yaml.dart';
class Flutter {
Flutter(YamlMap flutterMap) {
if (flutterMap != null) {
assets = FlutterAssets(safeCast<YamlList>(flutterMap['assets']));
fonts = FlutterFonts(safeCast<YamlList>(flutterMap['fonts']));
if (flutterMap.containsKey('assets')) {
assets = FlutterAssets(safeCast<YamlList>(flutterMap['assets']));
}
if (flutterMap.containsKey('fonts')) {
fonts = FlutterFonts(safeCast<YamlList>(flutterMap['fonts']));
}
}
}

Expand Down
8 changes: 6 additions & 2 deletions lib/src/settings/flutter_gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ class FlutterGen {
FlutterGen(YamlMap flutterGenMap) {
if (flutterGenMap != null) {
_output = safeCast<String>(flutterGenMap['output']);
integrations = FlutterGenIntegrations(
if (flutterGenMap.containsKey('integrations')) {
integrations = FlutterGenIntegrations(
safeCast<YamlMap>(flutterGenMap['integrations']));
}
_lineLength = safeCast<int>(flutterGenMap['lineLength']);
colors = FlutterGenColors(safeCast<YamlMap>(flutterGenMap['colors']));
if (flutterGenMap.containsKey('colors')) {
colors = FlutterGenColors(safeCast<YamlMap>(flutterGenMap['colors']));
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions test/flutter_gen_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ void main() {
});

test('Assets with No inegrations on pubspec.yaml', () async {
await FlutterGenerator(
File('test_resources/pubspec_assets_no_integrations.yaml'))
.build();
expect(
File('test_resources/lib/gen/assets.gen.dart').readAsStringSync(),
isNotEmpty,
);

final pubspec = File('test_resources/pubspec_assets_no_integrations.yaml');
final config = await Config(pubspec).load();
final formatter = DartFormatter(pageWidth: config.flutterGen.lineLength);
Expand Down

0 comments on commit 905324e

Please sign in to comment.