2

I have a problem with flutter the assets below are not displayed inside the widget, it tells me unable to load assetss how can I do to fix this?

Dart Code:

final cookingEvent = Event(
    imagePath: "assets/event_images/granite_cooking_class.jpeg",
    title: "Basket",
    description: "",
    location: "Ferrara(FE)",
    duration: "1ms",
    punchLine1: "Partecipa!",
    punchLine2: "nuova partita di calcio",categoryIds: [0, 2],
    galleryImages: ["assets/event_images/cooking_1.jpeg", "assets/event_images/cooking_2.jpeg", "assets/event_images/cooking_3.jpeg"]);

Flutter Exception:

r:   "assets/event_images/5_km_downtown_run.jpeg", scale: 1.0)
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: Unable to load asset: assets/event_images/granite_cooking_class.jpeg
flutter: Another exception was thrown: Unable to load asset: assets/event_images/music_concert.jpeg
flutter: Another exception was thrown: Unable to load asset: assets/event_images/golf_competition.jpeg

Pubspec.yaml:

assets:
   - assets/guest_images/
   - assets/event_images/
   - assets/fonts/

fonts:
    - family: Montserrat
      fonts:
          weight: 700
5
  • Make sure the image path is correct and restart the application. Not hot-restart / reload. Close the app and run again. Commented Feb 28, 2021 at 7:47
  • i have try but i havd always error Commented Feb 28, 2021 at 7:48
  • Silly question: have you already run flutter pub get? Commented Feb 28, 2021 at 7:55
  • Can you make sure this file exists in the directory? assets/event_images/5_km_downtown_run.jpeg Check the spelling correctly Commented Feb 28, 2021 at 9:34
  • Yes file existing Commented Feb 28, 2021 at 9:34

1 Answer 1

2
  1. Make sure that the path of your image is correct.
  2. Then check for tab spaces.

an example for point 2

  1. make sure to run flutter pub get command.
  2. Then restart your app or hot reload your app.
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.