Reputation: 1503
When trying to add images inside gridview.count Widget. Images are not getting loaded and getting flowing error in console.
Images are placed in local - asset Folder
body: center(
child:gridview.count(
crossaxiscount: 3,
childaspectratio: 1.0,
padding: const edgeinsets.all(4.0),
mainaxisspacing: 4.0,
crossaxisspacing: 4.0,
children: <string>[
'spinach_onion_salad.png',
'veggie.png',
].map<widget>((string url) {
return gridtile(
footer: gridtilebar(
title: text(url)
),
child: image.network(url, fit: boxfit.cover)
);
}).tolist(),
),
),
Error:
Error::
Reloaded 0 of 426 libraries in 937ms.
Reloaded 6 of 426 libraries in 1,338ms.
I/flutter (32327): ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
I/flutter (32327): The following ArgumentError was thrown resolving an image codec:
I/flutter (32327): Invalid argument(s): No host specified in URI file:///%20eggie.png
I/flutter (32327):
I/flutter (32327): When the exception was thrown, this was the stack:
I/flutter (32327): #0 _HttpClient._openUrl (dart:_http/http_impl.dart:2121:9)
I/flutter (32327): #1 _HttpClient.getUrl (dart:_http/http_impl.dart:2056:48)\
Upvotes: 2
Views: 7587
Reputation: 2329
return Container(
child: Center(
child: GridView.count(
crossAxisCount: 3,
childAspectRatio: 1.0,
padding: const EdgeInsets.all(4.0),
mainAxisSpacing: 4.0,
children: <String>[
'spinach_onion_salad.png',
'veggie.png',
]
.map<Widget>((String url) => GridTile(
footer: GridTileBar(title: Text(url)),
child: Image.asset(url)))
.toList(),
),
),
);
Upvotes: 0