From 9a1f8281c97b8b68dacda3a9984fe614f73d5b85 Mon Sep 17 00:00:00 2001 From: Ratakondala Arun Date: Sun, 10 Jul 2022 12:09:25 +0530 Subject: [PATCH] fix(config): type error when invalid config is passed --- lib/flutter_launcher_icons_config.dart | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/flutter_launcher_icons_config.dart b/lib/flutter_launcher_icons_config.dart index b758795de9..59df952b0f 100644 --- a/lib/flutter_launcher_icons_config.dart +++ b/lib/flutter_launcher_icons_config.dart @@ -66,9 +66,15 @@ class FlutterLauncherIconsConfig { } final configContent = configFile.readAsStringSync(); try { - return yaml.checkedYamlDecode( + return yaml.checkedYamlDecode( 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); @@ -88,11 +94,12 @@ class FlutterLauncherIconsConfig { return yaml.checkedYamlDecode( 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);