问题
════════ 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