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