Tried to use both NetworkImage
and Image.network()
methods to load jpg image from the Web, in both cases it says that there is "ImageCodecException" and it's "Fialed to load network image". Tried in DartPad.
This code:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body:
// Load image from network
new Image.network(
'https://www.nasa.gov/i开发者_JAVA百科mages/content/162056main_PIA08329.jpg'),
),
);
}
}
At first try to wrap your Image.network to Center or something to align Image and the second one is check your url that you provide, you need to provide actual path for that just click to image and simply select "copy image adress" and put it in url. You can also check how to do it here - https://youtu.be/Ln2xvLs6dc4
精彩评论