vendredi 7 juin 2019

I have a problem adding an image to a flutter project

I am experimenting with a flutter web project (might not make a difference but worth mentioning), i want to add an image but i get an error every time i try,

I have added the right assets to the pubspec.yaml file and the files are in the folder.

i have tried restarting my ide, and flutter clean. There was no change at all.

class _homePageState extends State<homePage> {
  @override
  Widget build(BuildContext context) {
    var textStyle = TextStyle(
                    color: Colors.black,
                    fontSize: 30,
                    fontWeight: FontWeight.w100,
                );

    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        fontFamily: "MontSerrat"
      ),

      home: Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.grey[400],
          title: Text("Germain Leignel",
            style: TextStyle(
              color: Colors.black,
              fontSize: 40,
              fontWeight: FontWeight.w100,
            ),
          )
        ),
        body: 
        Container(
          color: Colors.grey[400],
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Image.asset('assets/images/first_image.jpg')
            ],
          ),
        )
      ),
    );
  }
}

i expect my code to display an image, however i get an error message,

Unable to load asset: assets/images/first_image.jpg




Aucun commentaire:

Enregistrer un commentaire