I am trying to create a splash screen using flutter_native_splash 1.3.1 package. I created a folder called 'assets' in the lib folder and added that image to that folder. But I am getting the error mentioned in the question when I ran 'flutter pub run flutter_native_splash:create
' in the command line.
I added the following lines in pubspec.yaml as suggested by the package documentation.
flutter_native_splash:
color: "#000000"
image: assets/background.png
Can someone please explain what I might be missing?
CodePudding user response:
Do the following steps
- Add flutter_native_splash: ^1.3.1 in pubspec.yaml
- Create flutter_native_splash.yaml in root of project at same level as pubspec.yaml
- Add below content in the above file
flutter_native_splash:
color: "#000000"
image: assets/background.png
- Run this command in terminal
flutter pub run flutter_native_splash:create
- With above steps, splash screen will load properly but the error you mentioned might come. To remove that error enable below section in pubspec.yaml
assets:
- assets/background.png
6.Make sure you have assets directory in the root of project and background.png is present inside it.
7.Clean and build. it should work without any issues
CodePudding user response:
Continuing the Ehtesham Siddiquie answer. I think the assets folder should be at the root of the project (at the same level of pubspec.yaml and flutter_native_splash.yaml). but u created it in the lib folder.