简体   繁体   English

颤振错误:参数类型“未来”<Image> &#39; 不能分配给参数类型 &#39;Widget&#39;

[英]flutter error:The argument type 'Future<Image>' can't be assigned to the parameter type 'Widget'

i'm using flutter flame library and got this error我正在使用颤振火焰库并收到此错误

The argument type 'Future<Image>' can't be assigned to the parameter type 'Widget'.

my code is:我的代码是:

import 'package:flutter/material.dart';
import 'package:flame/flame.dart';

class TileMap extends StatefulWidget {
  @override
  _TileMapState createState() => _TileMapState();
}

class _TileMapState extends State<TileMap> {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Flame.images.load('grass_05.png'),
    );
  }
}

how to fix it?如何解决? and what's the problem?有什么问题? thank's to all谢谢大家

class _TileMapState extends State<TileMap> {
  @override
  void initState() {
    super.initState();
    _loadImage()
  }

  void _loadImage() async {
    var img = await Flame.images.load('grass_05.png');
    setState(() => _image = img);
  }

  Image _image;

  @override
  Widget build(BuildContext context) {
    return Container(
      child: _image,
    );
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Flutter 错误:参数类型“列表” <future<widget> &gt;' 不能分配给参数类型 'List<widget> ' </widget></future<widget> - Flutter error : The argument type 'List<Future<Widget>>' can't be assigned to the parameter type 'List<Widget>' 参数类型'Future<listview> ' 不能分配给参数类型 'Widget?'</listview> - The argument type 'Future<ListView>' can't be assigned to the parameter type 'Widget?' 错误:参数类型“未来”<widget> ' 不能分配给参数类型 'Widget'</widget> - Error: The argument type 'Future<Widget>' can't be assigned to the parameter type 'Widget' flutter / dart 错误:参数类型 'Future<file> ' 不能分配给参数类型 'File'</file> - flutter / dart error: The argument type 'Future<File>' can't be assigned to the parameter type 'File' 错误:无法将参数类型“IconData”分配给参数类型“Widget” - Error: The argument type 'IconData' can't be assigned to the parameter type 'Widget' Flutter:无法将参数类型“Image”分配给参数类型“IconData” - Flutter : The argument type 'Image' can't be assigned to the parameter type 'IconData' 参数类型 &#39;Future<Widget> &#39; 不能分配给参数类型 &#39;Widget&#39;.dart - The argument type 'Future<Widget>' can't be assigned to the parameter type 'Widget'.dart Flutter listener error The argument Type can't be assigned to the parameter type - Flutter listener error The argument Type can't be assigned to the parameter type Flutter - 错误:无法将参数类型“图像”分配给参数类型---解决方案? - Flutter - Error: The argument type 'Image' can't be assigned to the parameter type --- solution? 参数类型 &#39;Future<xxx> &#39; 不能分配给参数类型 &#39;FutureOr<xxx> &#39; 颤振和飞镖 - The argument type 'Future<xxx>' can't be assigned to the parameter type 'FutureOr<xxx>' Flutter & Dart
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM