'How to add an image to Flutter?

I have already done everything on this site of my app, but I wanted to add an image after I did my code to put a gradient in the background. Now when I try to add an image, everything (color of gradient and background) goes to the image instead, so I then have a white background and an image with these colors instead of the original image.

import 'package:flutter/material.dart';
import 'package:local_food_vrhnika/sidebar.dart';
import 'package:local_food_vrhnika/style/style.dart';

class FirstPage extends StatelessWidget {
  const FirstPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: new AppBar(
        backgroundColor: rdecaDva,
        shadowColor: Colors.black,
        centerTitle: true,
        title: RichText(
            text: TextSpan(
                style: TextStyle(fontWeight: FontWeight.bold),
                children: [
              TextSpan(
                  text: 'Local',
                  style:
                      naslov(textStyle: TextStyle(color: tekst, fontSize: 25))),
              TextSpan(
                  text: 'food',
                  style: naslov(
                      textStyle: TextStyle(color: oranznaDva, fontSize: 20))),
              TextSpan(
                  text: 'Vrhnika',
                  style:
                      naslov(textStyle: TextStyle(color: tekst, fontSize: 25)))
            ])),
        /*leading: IconButton(
          icon: new Icon(Icons.food_bank),
          onPressed: () => Scaffold.of(context).openDrawer(),
        ),*/
      ),
      drawer: SideDrawer(),
      body: Center(
        child: Container(
          decoration: BoxDecoration(
              gradient: LinearGradient(
                  begin: Alignment.topCenter,
                  end: Alignment.bottomCenter,
                  colors: [oranzna!, oranznaDva!, rdecaDva!])),
          /*child: Container(
            child: Image.asset('assets/images/earth.png'),
            width: 200,
            height: 200,
          ),*/
        ),
      ),
    );
  }
}


Solution 1:[1]

Please add pubspec.YAML file when you insert an image in asset you should start the app from scratch delete the app and run again the app if still your image is not showing please see your pubspec file at there see asset pathand match with your container path

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MuhammadOmar