问题描述
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: Text(MyApp.title),centerTitle: true,),body: (()=>{
if(!list){
return Register();
}
else{
return Homepage();
}
})
);
我的应用程序在 init 上从本地存储中获取一个列表,然后下一个要呈现的页面取决于该列表是否为空。有没有办法根据条件确定要呈现的小部件?
解决方法
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: Text(MyApp.title),centerTitle: true,),body: list.isEmpty ? Register() : Homepage()
);