java - Flutter 无法从 url 加载图片

当我尝试从一个 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 解释为文件路径。

尝试明确设置协议(protocol):

body: new Image.network('http://www.google.de/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png'),

https://stackoverflow.com/questions/49222953/

相关文章:

dart - 有没有办法在 Flutter 的多个 PageRoutes 中使用 Inherited

dart - CustomScrollView 中的 Flutter 固定按钮

c# - 将 Flutter 前端与 Android 和 iOS 的 .NET Core 后端相结合

dart - 如何为屏幕设置不同的主题?

mobile - Dart:流与 ValueNotifiers

dart - 如何在 flutter 中调整芯片的大小

firebase - 使用 FirebaseAuth 、 Firestore 和 Google 登录

flutter - 如何在 flutter 的文本小部件中显示图标?

dart - const 在 Flutter 中定义 EdgeInsets 中的作用

dart - 如何使用 Flutter 在 Android 中显示 iOS/cupertino 警报