【发布时间】:2021-02-26 10:07:13
【问题描述】:
如何将 Future 小部件返回到 StatelessWidget?我自己尝试过一些东西,但它给出了错误:“类型'Future'不是'Widget'类型的子类型?'”。这是代码
recieveMessage() async {
var x = 'Test';
return Text(x);
}
class Test extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: recieveMessage(),
);
}
}
提前致谢。
【问题讨论】:
-
这能回答你的问题吗? What is a Future and how do I use it?
-
不,这并不可悲:(