return
Container(
color: Colors.transparent,
child:
Column(
children: <Widget>[
Container(
color: Colors.transparent,
height: 30,
child:
RaisedButton(
child:
Column(
children: <Widget>[
Text("Test"),
],
),
color: Colors.transparent,
elevation: 0,
splashColor: Colors.transparent,
//onPressed: () {
// Navigator.push(context, MaterialPageRoute(builder: (context) => ToSchoolScreen()));
//},
)
),
],
)
);
Run Code Online (Sandbox Code Playgroud)
我有一个像上面这样的代码。我想在几秒钟后返回这个容器。但如果我Future像这样直接使用
return
Future.delayed(Duration(milliseconds: 500), () {
Container(
color: Colors.transparent,
child:
Column(
children: <Widget>[
Container(
color: Colors.transparent,
height: 30,
child:
RaisedButton(
child:
Column(
children: <Widget>[
Text("Test"),
],
),
color: Colors.transparent,
elevation: 0,
splashColor: Colors.transparent,
//onPressed: () {
// Navigator.push(context, MaterialPageRoute(builder: (context) => ToSchoolScreen()));
//},
)
),
],
)
);
});
Run Code Online (Sandbox Code Playgroud)
我收到一个错误type `Future<dynamic> ' is not a subtype of type 'Widget'。如何解决这个问题呢?
FutureBuilder(
future: Future.delayed(Duration(milliseconds: 500)),
builder: (context, snapshot) {
// Checks whether the future is resolved, ie the duration is over
if (snapshot.connectionState == ConnectionState.done)
return MyWidget();
else
return Container(); // Return empty container to avoid build errors
}
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2214 次 |
| 最近记录: |