Exception caught by image resource service
(
height: 300,
width: double.maxFinite,
child: TabBarView(controller: _tabController, children: [
ListView.builder(
itemCount: 3,
itemBuilder: (BuildContext context, int index) {
return Container(
width: 200,
height: 300,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.white,
image: DecorationImage(
image: AssetImage(
"images/levender.jpg",
),
fit: BoxFit.cover,
),
),
);
When the exception was thrown, this was the stack C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/internal/js_dev_runtime/private/ddc_runtime/errors.dart 236:49 throw packages/flutter/src/services/asset_bundle.dart 224:55 load C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50 C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1362:47 _rootRunUnary C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/async/zone.dart 1265:19 runUnary ... Image provider: AssetImage(bundle: null, name: "images/levender.jpg") Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#0645c(), name: "images/levender.jpg", scale: 1)
CodePudding user response:
Please ensure you intialize your image asset in pubspec.yaml
assets:
- images/
and then call like
(
height: 300,
width: double.maxFinite,
child: TabBarView(controller: _tabController, children: [
ListView.builder(
itemCount: 3,
itemBuilder: (BuildContext context, int index) {
return Container(
width: 200,
height: 300,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.white,
image: DecorationImage(
image: AssetImage(
"images/levender.jpg",
),
fit: BoxFit.cover,
),
),
);
N.B: use commands flutter clean
, flutter pub get
and flutter run
CodePudding user response:
It will happen sometimes. sometimes when you add an asset if this error happened just close your emulator and run it again and it will be ok.