reorder method

void reorder(
  1. BuildContext context,
  2. PageState state,
  3. ID nodeID,
  4. int newIndex,
  5. int l,
  6. dynamic onReorder(
    1. int,
    2. int
    ),
)

Implementation

void reorder(
  BuildContext context,
  PageState state,
  ID nodeID,
  int newIndex,
  int l,
  Function(int, int) onReorder,
) {
  var loop = l;
  final node =
      state.nodes.firstWhereOrNull((element) => element.id == nodeID);
  if (node == null) throw Exception('No node found');
  if (node.children == null) throw Exception('No children found');
  onReorder(loop, newIndex);
  /*Logger.printWarning('ReorderListViewAction $loop ${node.children!.length}');
  final itemChildOne =
      node.children![loop].copyWith(childOrder: newIndex.toDouble());
  final itemChildTwo = node.children![newIndex]
      .copyWith(childOrder: newIndex.toDouble() + 0.1);
  context.read<TreeGlobalState>().onNodeUpdatedInPlayMode(
        itemChildOne,
      );
  context.read<TreeGlobalState>().onNodeUpdatedInPlayMode(
        itemChildTwo,
      );*/
}