Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled exception: type 'Null' is not a subtype of type 'Map<dynamic, dynamic>' in type cast #643

Closed
Ngochiendev opened this issue Dec 29, 2023 · 3 comments

Comments

@Ngochiendev
Copy link

Describe the bug
When I use this command dart run flutter_native_splash:create --path=native_splash_generator.yaml , an error appears like the image below
Error -> Building package executable...
Built flutter_native_splash:create.
Unhandled exception:
type 'Null' is not a subtype of type 'Map<dynamic, dynamic>' in type cast
#0 getConfig (package:flutter_native_splash/cli_commands.dart:350:67)
#1 createSplash (package:flutter_native_splash/cli_commands.dart:42:18)
#2 main (file:///Users/macos/.pub-cache/hosted/pub.dev/flutter_native_splash-2.3.8/bin/create.dart:31:5)
#3 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:295:33)
#4 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

Screenshots
Ảnh màn hình 2023-12-29 lúc 10 01 37

Please give me solution to fix this error

@jonbhanson
Copy link
Owner

Please add your config.

@jonbhanson
Copy link
Owner

Closed due to inactivity. Feel free to reopen if you're still having trouble.

@BujusKrachus
Copy link

I was experiencing the same issue. Though it's not an actual package issue, rather a documentation/usage one. I am adding this comment in case anybody else is confused.

Steps to reproduce:

  1. Create a new Flutter project. I used Android Studio and Flutter SDK 3.16.7 for it.
  2. run flutter pub add flutter_native_splash
  3. add flutter_native_splash: color: "#000000" to pubspec.yaml
  4. run dart run flutter_native_splash:create, this will work
  5. run dart run flutter_native_splash:create --path=splash.yaml, this will not work because splash.yaml does not yet exist
  6. Thus create a new file splash.yaml
  7. run dart run flutter_native_splash:create --path=splash.yaml again, this will not work because of the Unhandled exception: type 'Null' is not a subtype of type 'Map<dynamic, dynamic>' in type cast

Full output of command:

dart run flutter_native_splash:create --path=splash.yaml
Building package executable... 
Built flutter_native_splash:create.
Unhandled exception:
type 'Null' is not a subtype of type 'Map<dynamic, dynamic>' in type cast
#0      getConfig (package:flutter_native_splash/cli_commands.dart:350:67)
#1      createSplash (package:flutter_native_splash/cli_commands.dart:42:18)
#2      main (file:///C:/Users/user/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_native_splash-2.3.10/bin/create.dart:31:5)
#3      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:33)
#4      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

What's going on?
you either specify the parameters (splash config instructions) in pubspec.yaml and run dart run flutter_native_splash:create OR specify the parameters in a seperate file (e.g. splash.yaml) and run dart run flutter_native_splash:create --path=splash.yaml.
In my opinion the Readme is a bit misleading here and the exception output could be handled better. If someone has some time this could get improved.

Also maybe helpful to note: The splash screen will get displayed despite the error, as the issue is just a usage one (only use one command/method).

Future improvements

  • clarify usage in readme (2. Run the package)
  • handle exception better in case of no splash.yaml
  • handle exception better in case of no flutter_native_splash section in pubspec.yaml

Hope this helps any future readers :)

jonbhanson added a commit that referenced this issue Feb 18, 2024
…. Thanks BujusKrachus for the detailed explanation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants