Home > OS >  The file "assets/background.png" set as the parameter "image" was not found. pub
The file "assets/background.png" set as the parameter "image" was not found. pub

Time:11-06

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

  1. Add flutter_native_splash: ^1.3.1 in pubspec.yaml
  2. Create flutter_native_splash.yaml in root of project at same level as pubspec.yaml
  3. Add below content in the above file

flutter_native_splash:

color: "#000000"
image: assets/background.png
  1. Run this command in terminal

flutter pub run flutter_native_splash:create

  1. 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.

  • Related