Skip to content

Commit

Permalink
fix(config): type error when invalid config is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
RatakondalaArun committed Jul 10, 2022
1 parent b2b8982 commit 9a1f828
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/flutter_launcher_icons_config.dart
Expand Up @@ -66,9 +66,15 @@ class FlutterLauncherIconsConfig {
}
final configContent = configFile.readAsStringSync();
try {
return yaml.checkedYamlDecode<FlutterLauncherIconsConfig>(
return yaml.checkedYamlDecode<FlutterLauncherIconsConfig?>(
configContent,
(json) => FlutterLauncherIconsConfig.fromJson(json!['flutter_icons']),
(json) {
// todo: add support for new scheme https://github.com/fluttercommunity/flutter_launcher_icons/issues/373
return json == null || json['flutter_icons'] == null
? null
: FlutterLauncherIconsConfig.fromJson(json['flutter_icons']);
},
allowNull: true,
);
} on yaml.ParsedYamlException catch (e) {
throw InvalidConfigException(e.formattedMessage);
Expand All @@ -88,11 +94,12 @@ class FlutterLauncherIconsConfig {
return yaml.checkedYamlDecode<FlutterLauncherIconsConfig?>(
pubspecContent,
(json) {
if (json!['flutter_icons'] == null) {
return null;
}
return FlutterLauncherIconsConfig.fromJson(json['flutter_icons']);
// todo: add support for new scheme https://github.com/fluttercommunity/flutter_launcher_icons/issues/373
return json == null || json['flutter_icons'] == null
? null
: FlutterLauncherIconsConfig.fromJson(json['flutter_icons']);
},
allowNull: true,
);
} on yaml.ParsedYamlException catch (e) {
throw InvalidConfigException(e.formattedMessage);
Expand Down

0 comments on commit 9a1f828

Please sign in to comment.