I have an huge error when I try loading images from an url in flutter. I have uploaded it to hastebin: https://hastebin.com/iguvopihog.m
Here is my code:
import 'package:flutter/material.dart';
import 'package:test/news.dart';
void main() => runApp(new Main());
class Main extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Test',
home: new Scaffold(
body: new Image.network('www.google.de/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'),
appBar: new AppBar(
title: new Text("Test"),
actions: <Widget>[
new IconButton(icon: new Icon(Icons.menu), onPressed: null),
],
),
),
);
}
}
Displaying images is fundamental for most mobile apps. Flutter provides the Image widget to display different types of images. To work with images from a URL, use the Image.network() constructor.
For some reason Image.network
seems to interpret the URL as file path.
Try instead setting the protocol explicitely:
body: new Image.network('http://www.google.de/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With