diff --git a/CHANGELOG.md b/CHANGELOG.md index 1871e19..9f3cb4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [2.3.13] - (2024-Feb-18) + +- Added better exception handling based on [this comment](https://github.com/jonbhanson/flutter_native_splash/issues/643#issuecomment-1938416308). Thanks [BujusKrachus](https://github.com/BujusKrachus) for the detailed explanation. + ## [2.3.12] - (2024-Feb-18) - Fix incorrect rejection of parameter values. Fixes [#652](https://github.com/jonbhanson/flutter_native_splash/issues/652). diff --git a/README.md b/README.md index fc14814..78ddc7f 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ First, add `flutter_native_splash` as a dependency in your pubspec.yaml file. ```yaml dependencies: - flutter_native_splash: ^2.3.12 + flutter_native_splash: ^2.3.13 ``` Don't forget to `flutter pub get`. @@ -177,7 +177,7 @@ flutter_native_splash: ## 2. Run the package -After adding your settings, run the following command in the terminal: +After adding your settings to `pubspec.yaml`, run the following command in the terminal: ``` dart run flutter_native_splash:create @@ -185,7 +185,7 @@ dart run flutter_native_splash:create When the package finishes running, your splash screen is ready. -To specify the YAML file location just add --path with the command in the terminal: +(Optionally), If you added your config to a separate YAML file instead of `pubspec.yaml`, just add --path with the command in the terminal: ``` dart run flutter_native_splash:create --path=path/to/my/file.yaml diff --git a/lib/cli_commands.dart b/lib/cli_commands.dart index 3537252..6d94cf7 100644 --- a/lib/cli_commands.dart +++ b/lib/cli_commands.dart @@ -347,7 +347,12 @@ Map getConfig({ filePath = 'pubspec.yaml'; } - final Map yamlMap = loadYaml(File(filePath).readAsStringSync()) as Map; + final Map yamlMap; + try { + yamlMap = loadYaml(File(filePath).readAsStringSync()) as Map; + } catch (e) { + throw Exception('Your `$filePath` appears to be empty or malformed.'); + } if (yamlMap['flutter_native_splash'] is! Map) { throw Exception( diff --git a/pubspec.yaml b/pubspec.yaml index b527e25..819b36d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: flutter_native_splash description: Customize Flutter's default white native splash screen with background color and splash image. Supports dark mode, full screen, and more. -version: 2.3.12 +version: 2.3.13 repository: https://github.com/jonbhanson/flutter_native_splash issue_tracker: https://github.com/jonbhanson/flutter_native_splash/issues