runFunction method

Future runFunction(
  1. BuildContext context,
  2. ListViewAction action,
  3. int loop
)

Implementation

Future<dynamic> runFunction(
    BuildContext context, ListViewAction action, int loop) async {
  try {
    final controller = getVariable(context.pageState, action);
    if (controller.scrollController == null) {
      context.read<AppLogsCubit>().onNewLog(
            EditorLogEntity(
              id: _uuid.v1(),
              content: 'List View Controller not found',
              createdAt: DateTime.now(),
            ),
          );
      return;
    }
    if (action is ScrollToIndexAction) {
      scrollToIndex(controller.scrollController!, action.index);
      return;
    }
    if (action is ReorderListViewAction) {
      reorder(context, context.pageState, action.nodeID, action.index, loop,
          (_, __) {});
      return;
    }
    throw Exception('No function found');
  } catch (e) {
    context.read<AppLogsCubit>().onNewLog(
          EditorLogEntity(
            id: _uuid.v1(),
            content: e.toString(),
            createdAt: DateTime.now(),
          ),
        );
  }
  return;
}