断言失败:url!= null不正确

时间:2020-06-01 14:16:28

标签: api flutter dart

════════小部件库捕获到异常══════════════════════════════════ ═ 构建HomePage(dirty,state:_HomePageState#493d9)时引发了以下断言: 断言失败: F:\…\ painting_network_image_web.dart:23 url!= null 不是真的

这是我在home.dart中添加此代码时遇到的错误

WallpaperModel wallpaperModel = WallpaperModel();
wallpaperModel = WallpaperModel.fromMap(element);
wallpapers.add(wallpaperModel);

/widget/widget.dart

Widget wallpapersList({List<WallpaperModel> wallpapers, context}) { return Container( padding: EdgeInsets.symmetric(horizontal: 15.0), child: GridView.count( shrinkWrap: true, physics: ClampingScrollPhysics(), crossAxisCount: 2, childAspectRatio: 1.0, mainAxisSpacing: 5.0, crossAxisSpacing: 5.0, children: wallpapers.map((wallpaper) { return GridTile( child: Container( child: Image.network(wallpaper.src.portrait), ), ); }).toList(), ), ); }

flutter

这是我执行flutter clean并尝试运行flutter run -v

时遇到的错误

1 个答案:

答案 0 :(得分:1)

看到您的代码后,请更改

return SrcModel(
  orignal: jsonData["orignal"],
  small: jsonData["small"],
  portrait: jsonData["protrait"],
);

return SrcModel(
  orignal: jsonData["original"],
  small: jsonData["small"],
  portrait: jsonData["portrait"],
);

现在我看到了你的照片,我喜欢你的设计