Assertion failed: url != null is not true

半腔热情 提交于 2021-01-28 10:19:11

问题


════════ Exception caught by widgets library ═══════════════════════════════════ The following assertion was thrown building HomePage(dirty, state: _HomePageState#493d9): Assertion failed: F:\…\painting_network_image_web.dart:23 url != null is not true

This is the error I get when I add this codes in home.dart

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

also /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(), ), ); }

this is the error I get when I execute my code I tried to use flutter clean also then run flutter run -v


回答1:


After saw your code, please change

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

to

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

now I see your pics and I like your design



来源:https://stackoverflow.com/questions/62134248/assertion-failed-url-null-is-not-true

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!