Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

image not showing from internet using Image.network

Tags:

flutter

assets

import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/basic.dart';

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.blueGrey,
        appBar: AppBar(
          backgroundColor: Colors.blueGrey[900],
          title: Text("I AM RICH"),
        ),
        body: Center(
          child:Image(
            image: NetworkImage('https://images.pexels.com/photos/462118/pexels-photo-462118.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500'),
          ),
      ),
    ),
     debugShowCheckedModeBanner: false,
    )
  );
}
like image 527
Mehedi Hasan Avatar asked Jan 08 '20 01:01

Mehedi Hasan


People also ask

What is a network image?

They are different. NetworkImage class creates an object the provides an image from the src URL passed to it. It is not a widget and does not output an image to the screen. Image.network creates a widget that displays an image on the screen. It is just a named constructor on the Image class(a stateful widget).


1 Answers

In debug mode service extension and multiple permissions are enabled by default(in flutter)

as you are in release mode you have to add internet permission in androidmanifest.xml manually.( Just like you add it in native development)

navigate to android-> app-> src-> main-> AndroidManifest.xml and add this line outside of application scope.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
like image 91
Hossein Sohan Avatar answered Oct 03 '22 13:10

Hossein Sohan