+91 88606 33966            edu_sales@siriam.in                   Job Opening : On-site Functional Trainer/Instructor | Supply Chain Management (SCM)
How to Add Image in Flutter

To add an image in a Flutter app, you can use the Image widget or Image.asset,

Here are the some Steps that you have to follow.

  1. Place the image file in a location within your project.

Here You can see I’ve Created An assets folder, under Create Another Folder images, and paste your image into this folder.

2. Update pubspec.yaml:

Open your pubspec.yaml file.

you can find this file at the bottom of the project file structure.

Add a assets section

3. Use Image.asset Widget:

import ‘package:flutter/material.dart’;

class LoginScreen extends StatefulWidget {

  LoginScreen({super.key});

  @override

  State<LoginScreen> createState() => _LoginScreenState();

}

class _LoginScreenState extends State<LoginScreen> {

  @override

  Widget build(BuildContext context) {

    return Scaffold(

      body: Column(

        mainAxisAlignment: MainAxisAlignment.center,

          Image.asset(‘assets/images/on.jpg’),

         

    );

  }

}

4. Output

How to Add Image in Flutter

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top