skip to Main Content

I was taking a course which had old version of Flutter SDk which showed errors at main.dart files which I was able to eliminate by changing the dependencies in the .yaml file. But The file names color turned red when I did that change. Is it a problem or its just that way?

One other issue is again with the .yaml file where I cannot understand why it shows error when i use asset image from the folder. I followed exactly how the course instructed but the image is thrown everytime.
This is the code from the .yaml file

flutter:
  uses-material-design: true
  assets:
    - Images/diamond.png

and this is the code from the main file.

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      backgroundColor: Colors.blueGrey,
      appBar: AppBar(
        backgroundColor: Colors.blueGrey[900],
        title: const Center(child: Text('I am rich')),
      ),
      body: const Center(
        child: Image(image: AssetImage('Images/diamond.png')),
      ),
    ),
  ));
}

2

Answers


  1. There is no error in this you are good to go. Just reset the dependencies and by running flutter clean and it will solve the issue

    Login or Signup to reply.
  2. I didn’t see an error in your code. If you’re still getting errors, clean it with flutter clean. Click get dependency in the .yaml file and run your code again.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search