Displaying the image in Flutter works once
check this
assets:
- images/facebook.png
make sure you have same spaces exactly like this
flutter:
[2 whitespaces or 1 tab]assets:
[4 whitespaces or 2 tabs]- images/facebook.png
every space matters
Mohammed Ali
Updated on December 15, 2022Comments
-
Mohammed Ali over 1 year
I have a problem with flutter
Image.assets
, when I set image in the file and set it in the asset like that :`flutter: uses-material-design: true assets:
- images/facebook.png`
and when I put it in my code :
Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Image.asset( "images/facebook.png" ), Text( '$_counter', style: Theme.of(context).textTheme.display1, ), ], ), ),
and run it , it works well but the second time I run code , it not displaying and this the error I get :
I/flutter ( 4784): ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════ I/flutter ( 4784): The following assertion was thrown while resolving an image: I/flutter ( 4784): Unable to load asset: AssetManifest.json . . . I/flutter ( 4784): #381 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:969:5) I/flutter ( 4784): #382 RenderObjectToWidgetAdapter.attachToRenderTree. (package:flutter/src/widgets/binding.dart:915:17) I/flutter ( 4784): #383 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2328:19) I/flutter ( 4784): #384 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:914:13) I/flutter ( 4784): #385 WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:795:7) I/flutter ( 4784): #386 runApp (package:flutter/src/widgets/binding.dart:845:7) I/flutter ( 4784): #387 main (package:flutter_app/main.dart:4:16) I/flutter ( 4784): #388 _runMainZoned.. (dart:ui/hooks.dart:229:25) I/flutter ( 4784): #393 _runMainZoned. (dart:ui/hooks.dart:221:5) I/flutter ( 4784): #394
_startIsolate. (dart:isolate-patch/isolate_patch.dart:305:19) I/flutter ( 4784): #395 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12) I/flutter ( 4784): (elided 7 frames from package dart:async) I/flutter ( 4784): Image provider: AssetImage(bundle: null, name: "images/facebook.png") I/flutter ( 4784): Image configuration: ImageConfiguration(bundle: PlatformAssetBundle#b5447(), devicePixelRatio: 1.5, I/flutter ( 4784): locale: en_US, textDirection: TextDirection.ltr, platform: android) I/flutter ( 4784): ════════════════════════════════════════════════════════════════════════════════════════════════════