【发布时间】:2020-04-11 17:59:45
【问题描述】:
我是 Flutter 的新手,当我从 listView 中删除所有项目或 listView 为空时,我想显示像 No Record Found 这样的图像或文本。在 Android 中,我在这种情况下使用了 setEmptyView(),但我不知道如何在颤动中做到这一点。目前我正在通过 List 有人可以帮帮我吗?
DatabaseHelper databaseHelper = DatabaseHelper();
List<TaskModel> list;
int count = 0;
TaskModel taskModel;
@override
Widget build(BuildContext context) {
if (list == null) {
list = List<TaskModel>();
updateListView();
}
return Scaffold(
appBar: AppBar(
title: Text('Task'),
),
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.purple,
child: Icon(Icons.add),
onPressed: () {
Navigator.push(context,
new MaterialPageRoute<void>(builder: (context) {
return new CreateTask(TaskModel('', '', '', '', '', '', ''),'Add Task');
}));
}),
body: getTasListView()
);
}
ListView getTasListView(){
return ListView.builder(
itemCount: count,
itemBuilder: (BuildContext context, int position){
return Card(
color: Colors.white,
elevation: 2.0,
child: Column(
children: <Widget>[
ListTile(
title: Text(this.list[position].task),
onLongPress: () => navigateToDetail(this.list[position],'Edit Task'),
)
],
),
);
}
);
}
}
【问题讨论】:
标签: android ios flutter dart flutter-layout