'image not showing from internet using Image.network
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,
)
);
}
Solution 1:[1]
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" />
Solution 2:[2]
This happened to me today and i figured that my emulator was not connected to the internet.if you are facing this issue make sure your device you are using is connected to the internet.
Solution 3:[3]
Even I was facing the same problem until I checked that my device was not connected to the Internet and later turned it On the NetworkImage loaded the image from the URL string passed
Solution 4:[4]
You can use in Container
in your body
like this and wrap your Container
with Center
Widget
Container(
height: 90,
width: 90,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage("https://images.pexels.com/photos/462118/pexels-photo-462118.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"),
//whatever image you can put here
fit: BoxFit.cover,
),
),
),
Solution 5:[5]
Check if your emulator is able to access internet first. Try loading any url in Google Chrome inside emulator. If not, add the dns address 8.8.8.8 to your network settings.
Solution 6:[6]
Try adding below line in main/Manifest file.
android:usesCleartextTraffic="true"
You can get more detail by implementing errorBuilder listener in Image.network widget.
Solution 7:[7]
You should use the network
constructor. Please change this:
Image(
image: NetworkImage('https://images.pexels.com/photos/462118/pexels-photo-462118.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500'),
)
to this:
Image.network('https://images.pexels.com/photos/462118/pexels-photo-462118.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500')
Solution 8:[8]
I think your code is fine, to resolve this shutdown android studio & Emulator and restart it again. It works for me, and it keeps happening to me, I guess its because it couldn't load the photo
CircleAvatar(
backgroundImage: NetworkImage('https://www.pinclipart.com/picdir/big/218-2189254_free-online-avatars-kid-characters-family-vector-for.png'));
Solution 9:[9]
Also check if your phone connected to the internet.
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 | Hossein Sohan |
Solution 2 | |
Solution 3 | SagaRock101 |
Solution 4 | Aamil Silawat |
Solution 5 | Safnas |
Solution 6 | Dharmendra |
Solution 7 | |
Solution 8 | Sandeep Kumar |
Solution 9 | ramzieus |