I’m able to access the assets on every other page excluding the one I’m currently working on.
I’ve tried restarting, flutter doctor, flutter pub upgrade.
And "Shawarma" is text and not an image but it throws Another exception was thrown: Unable to load asset: "Shawarma".
══════════════╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞══════════════
The following assertion was thrown resolving an image codec:
Unable to load asset: "Sun, Sep 10, 2023 - 11:39 PM".
Exception: Asset not found
When the exception was thrown, this was the stack:
#0 PlatformAssetBundle.loadBuffer (package:flutter/src/services/asset_bundle.dart:295:7)
#1 AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:731:35)
#2 AssetBundleImageProvider.loadBuffer (package:flutter/src/painting/image_provider.dart:695:14)
#3 ImageProvider.resolveStreamForKey.<anonymous closure> (package:flutter/src/painting/image_provider.dart:513:13)
#4 ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:384:22)
#5 ImageProvider.resolveStreamForKey (package:flutter/src/painting/image_provider.dart:511:81)
#6 ScrollAwareImageProvider.resolveStreamForKey (package:flutter/src/widgets/scroll_aware_image_provider.dart:106:19)
#7 ImageProvider.resolve.<anonymous closure> (package:flutter/src/painting/image_provider.dart:358:9)
#8 ImageProvider._createErrorHandlerAndKey.<anonymous closure>
(package:flutter/src/painting/image_provider.dart:473:24)
#9 SynchronousFuture.then (package:flutter/src/foundation/synchronous_future.dart:41:39)
#10 ImageProvider._createErrorHandlerAndKey (package:flutter/src/painting/image_provider.dart:470:9)
#11 ImageProvider.resolve (package:flutter/src/painting/image_provider.dart:355:5)
#12 _ImageState._resolveImage (package:flutter/src/widgets/image.dart:1119:16)
#13 _ImageState.didChangeDependencies (package:flutter/src/widgets/image.dart:1069:5)
#14 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:5119:11)
#15 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4944:5)
... Normal element mounting (15 frames)
#30 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3953:16)
#31 Element.updateChild (package:flutter/src/widgets/framework.dart:3682:18)
#32 SlottedRenderObjectElement._updateChildren (package:flutter/src/widgets/slotted_render_object_widget.dart:270:33)
#33 SlottedRenderObjectElement.mount (package:flutter/src/widgets/slotted_render_object_widget.dart:224:5)
... Normal element mounting (192 frames)
#225 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3953:16)
#226 Element.updateChild (package:flutter/src/widgets/framework.dart:3682:18)
#227 SliverMultiBoxAdaptorElement.updateChild (package:flutter/src/widgets/sliver.dart:1451:37)
#228 SliverMultiBoxAdaptorElement.createChild.<anonymous closure> (package:flutter/src/widgets/sliver.dart:1436:20)
#229 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2682:19)
#230 SliverMultiBoxAdaptorElement.createChild (package:flutter/src/widgets/sliver.dart:1428:12)
#231 RenderSliverMultiBoxAdaptor._createOrObtainChild.<anonymous closure>
(package:flutter/src/rendering/sliver_multi_box_adaptor.dart:353:23)
#232 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:2300:59)
#233 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:1056:15)
#234 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:2300:14)
#235 RenderSliverMultiBoxAdaptor._createOrObtainChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:342:5)#236 RenderSliverMultiBoxAdaptor.addInitialChild (package:flutter/src/rendering/sliver_multi_box_adaptor.dart:428:5)
#237 RenderSliverList.performLayout (package:flutter/src/rendering/sliver_list.dart:79:12)
#238 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#239 RenderSliverEdgeInsetsPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:149:12)
#240 RenderSliverPadding.performLayout (package:flutter/src/rendering/sliver_padding.dart:386:11)
#241 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#242 RenderViewportBase.layoutChildSequence (package:flutter/src/rendering/viewport.dart:550:13)
#243 RenderShrinkWrappingViewport._attemptLayout (package:flutter/src/rendering/viewport.dart:1994:12)
#244 RenderShrinkWrappingViewport.performLayout (package:flutter/src/rendering/viewport.dart:1939:20)
#245 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#246 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#247 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#248 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#249 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#250 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#251 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#252 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#253 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#254 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#255 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#256 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#257 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#258 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#259 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#260 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#261 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#262 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#263 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#264 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#265 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#266 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#267 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#268 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#269 RenderCustomPaint.performLayout (package:flutter/src/rendering/custom_paint.dart:552:11)
#270 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#271 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#272 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#273 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#274 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#275 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11)
#276 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:836:43)
#277 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:938:32)
#278 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#279 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#280 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:240:12)
#281 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#282 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#283 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11)
#284 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:903:45)
#285 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:938:32)
#286 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#287 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#288 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11)
#289 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:836:43)
#290 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:938:32)
#291 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#292 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#293 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11)
#294 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:836:43)
#295 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:938:32)
#296 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#297 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#298 _RenderSingleChildViewport.performLayout (package:flutter/src/widgets/single_child_scroll_view.dart:502:14)
#299 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#300 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#301 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#302 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#303 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#304 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#305 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#306 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#307 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#308 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#309 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#310 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#311 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#312 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#313 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#314 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#315 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#316 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#317 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#318 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#319 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#320 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#321 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#322 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#323 RenderCustomPaint.performLayout (package:flutter/src/rendering/custom_paint.dart:552:11)
#324 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#325 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#326 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#327 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#328 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#329 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11)
#330 RenderStack._computeSize (package:flutter/src/rendering/stack.dart:595:43)
#331 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:622:12)
#332 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#333 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#334 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:171:12)
#335 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:1080:7)
#336 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:240:7)
#337 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:410:14)
#338 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#339 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#340 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#341 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#342 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#343 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#344 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1467:11)
#345 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#346 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#347 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#348 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#349 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#350 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#351 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#352 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#353 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#354 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#355 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#356 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#357 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#358 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#359 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#360 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#361 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#362 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#363 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#364 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#365 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#366 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#367 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#368 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#369 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#370 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#371 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#372 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#373 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#374 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3813:14)
#375 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#376 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#377 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:120:14)
#378 RenderObject.layout (package:flutter/src/rendering/object.dart:2189:7)
#379 RenderBox.layout (package:flutter/src/rendering/box.dart:2430:11)
#380 _RenderTheatre.performLayout (package:flutter/src/widgets/overlay.dart:856:15)
#381 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:2027:7)
#382 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:1020:18)
#383 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:516:19)
#384 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:865:13)
#385 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:381:5)
#386 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1289:15)
#387 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1218:9)
#388 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1076:5)
#389 _invoke (dart:ui/hooks.dart:145:13)
#390 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:338:5)
#391 _drawFrame (dart:ui/hooks.dart:112:31)
Image provider: AssetImage(bundle: null, name: "Sun, Sep 10, 2023 - 11:39 PM")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#591f7(), name: "Sun, Sep 10, 2023 - 11:39
PM", scale: 1.0)
══════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: Unable to load asset: "Shawarma".
This is the widget code:
Widget _buildNewCategory(String title, List<NotifPageItem> notifications) {
return Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.only(left: 20.0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Text(
title,
style: TextStyle(
fontSize: 26,
fontWeight: FontWeight.bold,
color: Colors.red.shade100,
),
),
const Expanded(child: Divider()),
Padding(
padding: const EdgeInsets.only(right: 8),
child: InkWell(
child: const Text('Mark as read'),
onTap: () {
if (newNotifications.isNotEmpty &&
thisWeekNotifications.isEmpty) {
thisWeekNotifications = [...newNotifications];
newNotifications.clear();
setState(() {});
} else {
for (int i = 0;
i < newNotifications.length;
i++) {
thisWeekNotifications.add(newNotifications[i]);
}
newNotifications.clear();
setState(() {});
}
},
),
)
],
),
),
const Divider(),
ListView.builder(
shrinkWrap: true,
physics: const ClampingScrollPhysics(),
itemCount: notifications.length,
itemBuilder: (context, index) {
int reverseIndex = notifications.length - 1 - index;
return Padding(
padding: const EdgeInsets.only(top: 8),
child: Padding(
padding: const EdgeInsets.only(right: 4),
child: Container(
height: 100,
decoration: BoxDecoration(
border: Border.all(color: Colors.red.shade300),
borderRadius: BorderRadius.circular(20),
),
child: Center(
child: ListTile(
leading: Image.asset(
notifications[reverseIndex].imgUrl),
title: Text(
notifications[reverseIndex].noOfItems == 1
? '${notifications[reverseIndex].notifTitle}n${notifications[reverseIndex].orderState}nYou ordered ${notifications[reverseIndex].foodTitle}'
: '${notifications[reverseIndex].notifTitle}n${notifications[reverseIndex].orderState}nYou ordered ${notifications[reverseIndex].foodTitle} + ${notifications[reverseIndex].noOfItems - 1}',
style: TextStyle(
color: Theme.of(context).primaryColor,
fontStyle: FontStyle.italic,
),
),
trailing: notifications[reverseIndex].noOfItems ==
1
? Stack(
children: [
Image.asset(
notifications[reverseIndex].varImgUrl,
height: 35,
width: 35,
),
Image.asset(
notifications[reverseIndex].imgUrl, //
height: 95,
width: 91,
),
],
)
: Stack(
children: [
Positioned(
right: 10,
bottom: 6,
child: Image.asset(
notifications[reverseIndex].imgUrl,
fit: BoxFit.cover,
height: 50,
width: 50,
colorBlendMode: BlendMode.lighten,
),
),
Image.asset(
notifications[reverseIndex].imgUrl,
height: 95,
width: 91,
),
],
),
subtitle: Text(
notifications[reverseIndex].time,
style: TextStyle(
color: Theme.of(context).primaryColor,
),
),
),
),
),
),
);
},
)
],
),
),
),
],
);
}
ff
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.7.6, on Microsoft Windows [Version 10.0.19045.2846], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.5.3)
[√] Android Studio (version 2021.3)
[√] Connected device (4 available)
[√] HTTP Host Availability
• No issues found!
2
Answers
It looks that the problem is about your data because you’re searching the image: "Sun, Sep 10, 2023 – 11:39 PM" and this doesnt look like an image (I think that your image can look like
assets/imgs/Sun, Sep 10, 2023 - 11:39 PM.jpg
), you need to be sure that you have this local image exactly as you have been registered on your pubspect.yamlOther possible error can be the way as you declare the assets on your pubspect.yaml, if you want to load an entire folder you need to declare the path of your images folder with a "/" in the end
It seems you’re providing the wrong asset name to your
Image.asset
widget. You’re providing the timestampSun, Sep 10, 2023 - 11:39 PM
as anasset path
in the image widget, which is incorrect. So, it means your code is searching for a timestamp in theassets folder
.