所以我在 Flutter 的项目管理应用程序中有一个 listview.builder 。这个列表视图充满了任务(它们可以是:新的、开始的、完成的)。我从 API 获取这些数据,并希望“新”的数据出现在顶部,开始的数据出现在中间,“已完成”的数据出现在底部!-这是现在的样子 这是我的Class,请注意我从 API/JSON 获取状态
class ProjectTask {
final int id;
final String description;
final String state;
final List assigned_users;
final List subtasks;
ProjectTask(this.id,
this.description,
this.state,
this.assigned_users,
this.subtasks);
}
Run Code Online (Sandbox Code Playgroud)
列表视图
else return ListView.builder(
itemCount: snapshot.data.length,
itemBuilder: (BuildContext context, int index) {
if(snapshot.data[index].state == "done") {
return Slidable(
//SLIDABLE STUFF
delegate: SlidableStrechDelegate(),
actionExtentRatio: 0.25,
actions: <Widget>[
//ACTION ONE
IconSlideAction(
caption: ("Information"),
foregroundColor: Colors.white,
color: Colors.black38,
icon: Icons.info,
onTap: () {
Navigator.push(context, MaterialPageRoute(builder: (context)=>projectTask(snapshot.data[index]))); …Run Code Online (Sandbox Code Playgroud)