首页 > 解决方案 > 颤振不加载资产

问题描述

我有一个颤动的问题,下面的资产没有显示在小部件内,它告诉我无法加载资产我该如何解决这个问题?

飞镖代码:

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"]);

颤振异常:

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

发布规范.yaml:

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

fonts:
    - family: Montserrat
      fonts:
          weight: 700

标签: flutterdart

解决方案


  1. 确保图像的路径正确。
  2. 然后检查制表符空格。

第 2 点的示例

  1. 确保运行flutter pub get命令。
  2. 然后重新启动您的应用程序或热重新加载您的应用程序。

推荐阅读