flutter移植DragAbleGridView官方demo长按图标实现拖拽、删除功能,移植到工程里面代码后报错!
代码如下:
static commonFuctionsEdit(BuildContext context) {
DragAbleGridViewState dragAbleGridViewState = new DragAbleGridViewState();
List<ItemBin> itemBins = new List();
var editSwitchController= EditSwitchController();
final List<String> icons1 = [
'assets/images/gongsi_kaoqinguanli3.png',
'assets/images/gongsi_xinchouguanli3.png',
'assets/images/gongsi_zhaopinguanli3.png',
'assets/images/gongsi_renshidangan3.png',
'assets/images/gongsi_videomeeting.png',
'assets/images/gongsi_wanxingxuetang3.png',
'assets/images/gongsi_yunyingbaogao3.png'
];
icons1.forEach((value) {
itemBins.add(new ItemBin(value));
//print(value);
});
dragAbleGridViewState.initState();
if(null != editSwitchController){
editSwitchController.editStateChanged();
}
return Scaffold(
body: editSwitchController != null ? DragAbleGridView(
mainAxisSpacing:10.0,
crossAxisSpacing:10.0,
childAspectRatio:1.0,
crossAxisCount: 4,
itemBins: itemBins,
editSwitchController:editSwitchController,
isOpenDragAble: true, //长按实现拖动的功能
animationDuration: 300, //milliseconds
longPressDuration: 800, //milliseconds
deleteIcon: Image.asset("assets/images/close.png",width: 15.0 ,height: 15.0 ),
//通过调用delete监听器实现对items的删除
deleteIconClickListener: (index) {},
child: (int position){
return Container(
child: Image.asset(
itemBins[position].data,
width: 50.0,
height: 50.0,
),
);
},
// child: ,
):Container(),
);
}
我也判空了啊,
大佬们有遇到过的嘛,头疼ing
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论