No file or variants found for asset: assets/images

Viewed 1264

loginpage.dart

 child: Column(children: [Image.asset("assets/images/loginimage.png")],),

assets file are

 assets:
    - assets/images
         # - images/a_dot_ham.jpeg

error is

Error detected in pubspec.yaml: No file or variants found for asset: assets/images.

FAILURE: Build failed with an exception.

  • Where: Script 'C:\Src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991

  • What went wrong: Execution failed for task ':app:compileFlutterBuildDebug'.

Process 'command 'C:\Src\flutter\bin\flutter.bat'' finished with non-zero exit value 1

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 4m 42s Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 289.8s Exception: Gradle task assembleDebug failed with exit code 1

3 Answers

Check the spaces. Generally, it should have three spaces from the start of the new line.

assets:

  • assets/images //make sure it has three spaces

Can you try edit your pubspec.yaml file like this.

assets:
- assets/images/

The pubspec.yaml file is the issue. Make this change.

assets:
  - assets/images/

NOTE: Spaces in .yaml file is VERY important. make sure your .yaml looks like this.

There may be less files, but the spaces are to be noted

Related