我尝试了一些方法,但没有得到确切的结果。
在列表功能中的某些记录停止工作后,如何在可重排的列表视图中实现拉动刷新以刷新。而且,可重新排序的列表在没有列表项的列表末尾占用更多空间。
产生拉动刷新的代码
Widget todoList() {
return StreamBuilder<dynamic>(
stream: toDoBloc.getTodos,
builder: (BuildContext context, AsyncSnapshot<dynamic> snap) {
if (!snap.hasData) {
return Center(
child: SizedBox(
height: 30.0,
width: 30.0,
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.blue),
),
),
);
} else {
_refreshController.refreshCompleted();
return SmartRefresher(
enablePullDown: true,
controller: _refreshController,
onRefresh: () async {
await Future<dynamic>.delayed(
const Duration(milliseconds: 1000),
);
toDoBloc.toDoList(
prefsObject.getString('circleId'),
);
},
header: ClassicHeader(
key: centerKey,
completeIcon: null,
),
child: listView(snap.data),
);
}
});
}
使列表可重新排序的代码
Widget listview(list) {
final List child = map<Widget>(list, (index, i) {
return _singleToDoWidget(list[index], index);
});
void _onReorder(int oldIndex, int newIndex) {
setState(() {
if (newIndex > oldIndex) {
newIndex -= 1;
}
final List oldIndexIds = map<String>(list, (index, i) {
return list[index].id;
});
final dynamic selectedListItem = list[oldIndex];
list.removeAt(oldIndex);
list.insert(newIndex, selectedListItem);
final List newIndexIds = map<String>(list, (index, i) {
return list[index].id;
});
toDoBloc.toDoOrderList(oldIndexIds, newIndexIds);
});
}
return ReorderableListView(
header: null, onReorder: _onReorder, children: child);
}
我实现拉动以使用RefreshIndicator class在可重新排序的列表视图中刷新
Future<dynamic> refreshList() async {
await Future.delayed(const Duration(seconds: 1));
return null; //do some here.
}
Widget todoList() {
return StreamBuilder<dynamic>(
stream: toDoBloc.getTodos,
builder: (BuildContext context, AsyncSnapshot<dynamic> snap) {
if (!snap.hasData) {
return Center(
child: SizedBox(
height: 30.0,
width: 30.0,
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.blue),
),
),
);
} else {
_refreshController.refreshCompleted();
return RefreshIndicator(
key: refreshKey,
color: pinkColor,
onRefresh: () async {
await refreshList();
},
child: _listView(snap.data),
);
}
});
}
• Bootstrap 表标题在 vuejs 组件中未正确对齐
• 如何在 Flutter Cupertino 应用程序中制作可重新排序的列表?
• 我如何将图像数据从 recyclerview 传递到新的活动图像视图
• 如何触发从 Flutter 屏幕获取输入的 AWS Lambda 函数
• 如何在 flutter 的分组列表视图中滚动到自定义索引?
• 如何在 React Native 中将多个平面列表放在一个全局滚动视图中?
• Django、DRF:仅在第一页删除序列化程序的特定字段
• R 如何根据请求列表对 asnyc curl 响应进行排序/重新排序?
• 如何将 ReorderableListView 与 ListView.builder 一起使用