Exception caught by image resource service I am getting error while running the following code.
Code:
import 'package:flutter/material.dart';
void main(){
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('PITCH'),
),
body: Column(
children: <Widget>[
new Text('WELCOME'),
new Image(image: AssetImage('download.png'))
],
),
),
);
}
}
Error:
flutter: ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════ flutter: The following assertion was thrown resolving an image codec: flutter: Unable to load asset: download.png flutter: flutter: When the exception was thrown, this was the stack: flutter: #0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:221:7) flutter: flutter: #1 AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:464:44) flutter: flutter: #2 AssetBundleImageProvider.load (package:flutter/src/painting/image_provider.dart:449:14) flutter: #3 ImageProvider.resolve... (package:flutter/src/painting/image_provider.dart:316:48) flutter: #4 ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:160:22) flutter: #5 ImageProvider.resolve.. (package:flutter/src/painting/image_provider.dart:316:25) flutter: (elided 13 frames from package dart:async) flutter: flutter: Image provider: AssetImage(bundle: null, name: "download.png") flutter: Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#ea200(), name: "download.png", scale: flutter: 1.0)