Skip to content
Readerstacks logo Readerstacks
  • Home
  • Softwares
  • Angular
  • Php
  • Laravel
  • Flutter
Readerstacks logo
Readerstacks
Display Remote Image in Flutter

How to show remote image in flutter application?

Aman Jain, January 2, 2022January 15, 2022

In this tutorial we will learn to show image in flutter. In flutter there is two types of images we can show one is asset image and other one is network image.

To use the images in flutter we have Image class which supports both local and remote images. For asset images we need to define it in pubspec.yaml first. Asset images are images which is stored locally in app directory and Network images are images which is stored in server. We can access Asset images using AssetImage class or Image.asset class.

Display remote image in flutter

Remote image or network image can be displayed easily in flutter application using Image.network method which accept first parameter as URL of image and other parameters for configuration of image.

Let’s understand with an example

Step 1 : Create flutter project

Very first step is to create the fluter application using command line tool or in Android studio.

flutter create example_app

This will create a new project with name my_app then go in to the folder .

Step 2 : Create a simple widget

Now, Create a simple stateless widget to show the image and it will consist a container and center widget to center the image as below

File : lib/remoteimagedemo.dart

import 'package:flutter/material.dart';

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

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Container(
      color: Colors.white,
      child: Center(
        child: Image.network('https://picsum.photos/200'),
      ),
    );
  }
}

Step 3: Import and use the widget in main

We just created a new widget with name remoteimagedemo, now we are going to use it in our main.dart file as below

import 'package:example_app/remoteimagedemo.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(

        primarySwatch: Colors.blue,
      ),
      home: const  RemoteImageDemo(),
    );
  }
}

Step 4: Run the project

Simply run the project using command line or in android studio to check the implementation.

flutter run lib/main.dart
Screenshot 2022 01 02 at 4.09.24 PM

Related

Dart Flutter FluttterimageRemote

Post navigation

Previous post
Next post

Related Posts

Dart flutter refresh page on back

How to refresh a page or widget on navigation pop/back in flutter ?

April 28, 2022November 5, 2023

Sometime in out application we want to refresh a page or widget on navigation pop/back in flutter because we want to update the state of our page so users can see the latest update based on their actions. So In this article I will show you to flutter refresh page…

Read More
Dart How to add one side border to container widget flutter

How to add one side border to container widget flutter?

September 17, 2022March 16, 2024

In this tutorial we will learn to add add one side border to container widget flutter. Border is used to create border around the widget or container and using the border we can style it in different way like adding the width of border, color of border and one side…

Read More
Dart How to create a scroll view in flutter

How to create a scroll view in flutter ?

January 8, 2022November 5, 2023

Flutter provides multiple way to scroll the view and one of the most efficient way is ListView.builder. Using the ListView class we can configure multiple options. Using these widgets we can create horizontal as well vertical scroll. ListView GridView CustomScrollView DraggableScrollableSheet NestedScrollView PageView SingleChildScrollView Here are the few scroll widgets…

Read More

Aman Jain
Aman Jain

With years of hands-on experience in the realm of web and mobile development, they have honed their skills in various technologies, including Laravel, PHP CodeIgniter, mobile app development, web app development, Flutter, React, JavaScript, Angular, Devops and so much more. Their proficiency extends to building robust REST APIs, AWS Code scaling, and optimization, ensuring that your applications run seamlessly on the cloud.

Categories

  • Angular
  • CSS
  • Dart
  • Devops
  • Flutter
  • HTML
  • Javascript
  • jQuery
  • Laravel
  • Laravel 10
  • Laravel 11
  • Laravel 9
  • Mysql
  • Php
  • Softwares
  • Ubuntu
  • Uncategorized

Archives

  • June 2025
  • May 2025
  • April 2025
  • October 2024
  • July 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • July 2023
  • March 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Recent Posts

  • The Resilience of Nature: How Forests Recover After Fires
  • Understanding Laravel Cookie Consent for GDPR Compliance
  • Understanding High Vulnerabilities: A Critical Overview of the Week of May 12, 2025
  • Installing a LAMP Stack on Ubuntu: A Comprehensive Guide
  • Understanding High Vulnerabilities: A Deep Dive into Recent Security Concerns
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version