onListLongpress method
void
onListLongpress({
- required int listIndex,
- required BuildContext context,
- required VoidCallback setstate,
Implementation
void onListLongpress(
{required int listIndex,
required BuildContext context,
required VoidCallback setstate}) {
var prov = ref.read(ProviderList.boardProvider);
for (var element in prov.board.lists) {
if (element.context == null) break;
var of = (element.context!.findRenderObject() as RenderBox)
.localToGlobal(Offset.zero);
element.x = of.dx - prov.board.displacementX!;
element.width = element.context!.size!.width - 30;
element.height = element.context!.size!.height - 30;
element.y = of.dy - prov.board.displacementY!;
}
var box = context.findRenderObject() as RenderBox;
var location = box.localToGlobal(Offset.zero);
prov.updateValue(
dx: location.dx - prov.board.displacementX! - 10,
dy: location.dy - prov.board.displacementY! + 24);
prov.board.dragItemIndex = null;
prov.board.dragItemOfListIndex = listIndex;
prov.draggedItemState = DraggedItemState(
child: Container(
width: box.size.width - 30,
height: box.size.height - 30,
color: prov.board.lists[listIndex].backgroundColor,
child: Column(children: [
Container(
margin: const EdgeInsets.only(
top: 20,
),
padding: const EdgeInsets.only(left: 15, bottom: 10),
alignment: Alignment.centerLeft,
child: Text(
prov.board.lists[listIndex].title,
style: const TextStyle(
fontSize: 20,
color: Colors.black,
fontWeight: FontWeight.bold),
),
),
Expanded(
child: MediaQuery.removePadding(
context: context,
removeTop: true,
child: ListView.builder(
physics: const ClampingScrollPhysics(),
controller: null,
itemCount: prov.board.lists[listIndex].items.length,
shrinkWrap: true,
itemBuilder: (ctx, index) {
return Item(
color: prov.board.lists[listIndex].items[index]
.backgroundColor ??
Colors.grey.shade200,
itemIndex: index,
listIndex: listIndex,
);
},
// itemCount: prov.items.length,
),
),
),
]),
),
listIndex: listIndex,
itemIndex: null,
height: box.size.height - 30,
width: box.size.width - 30,
x: location.dx - prov.board.displacementX!,
y: location.dy - prov.board.displacementY!);
prov.draggedItemState!.setState = () => setstate;
prov.board.dragItemIndex = null;
prov.board.isListDragged = true;
prov.board.dragItemOfListIndex = listIndex;
setstate();
}