[英]Flutter cannot load image from url
当我尝试从一个网址中加载图片时,我遇到了一个巨大的错误。 我已将其上传到hastebin: https ://hastebin.com/iguvopihog.m
这是我的代码:
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),
],
),
),
);
}
}
出于某种原因, Image.network
似乎将URL解释为文件路径。
尝试明确地设置协议:
body: new Image.network('http://www.google.de/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.