[英]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.