加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

java – Flutter无法从url加载图像

发布时间:2020-12-14 14:51:38 所属栏目:百科 来源:网络整理
导读:当我尝试从一个网址中加载图片时,我遇到了一个巨大的错误.我已将其上传到hastebin: https://hastebin.com/iguvopihog.m 这是我的代码: import 'package:flutter/material.dart';import 'package:test/news.dart';void main() = runApp(new Main());class M
当我尝试从一个网址中加载图片时,我遇到了一个巨大的错误.我已将其上传到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'),

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读