I tried everything but nothing seems to work. According to me, the path of the image is correct. (though I have attached an image for reference). This is the error I am getting -
════════ Exception caught by image resource service ════════════════════════════
The following assertion was thrown resolving an image codec:
Unable to load asset: start.png
When the exception was thrown, this was the stack
#0 PlatformAssetBundle.load
package:flutter/…/services/asset_bundle.dart:225
<asynchronous suspension>
#1 AssetBundleImageProvider._loadAsync
package:flutter/…/painting/image_provider.dart:668
#2 AssetBundleImageProvider.load
package:flutter/…/painting/image_provider.dart:651
#3 ImageProvider.resolveStreamForKey.<anonymous closure>
package:flutter/…/painting/image_provider.dart:504
...
Image provider: AssetImage(bundle: null, name: "start.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#2bd13(), name: "start.png", scale: 1.0)
════════════════════════════════════════════════════════════════════════════════
this is **pubspec.yaml*-
name: foodfast description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment: sdk: ">=2.7.0 <3.0.0"
dependencies: flutter: sdk: flutter
splashscreen: ^1.3.5
cupertino_icons: ^1.0.0 firebase_auth: ^0.20.0+1 cloud_firestore: ^0.16.0
dev_dependencies: flutter_test: sdk: flutter
flutter:
uses-material-design: true
assets: - assets/start.png
sign_in.dart
import 'package:flutter/material.dart';
class SignIn extends StatefulWidget {
@override
_SignInState createState() => _SignInState();
}
class _SignInState extends State<SignIn> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
title: new Text('sign in'),
),
backgroundColor: Colors.white,
body: Center(
child: ListView(
children: <Widget>[
Image(image: AssetImage('start.png'), fit: BoxFit.cover),
new Text('text below image')
],
)),
);
}
}