dispatchFunction method

  1. @override
void dispatchFunction(
  1. ViewPagerRenderViewModel? viewModel,
  2. String functionName,
  3. VoltronArray array, {
  4. Promise? promise,
})
override

Implementation

@override
void dispatchFunction(
  ViewPagerRenderViewModel? viewModel,
  String functionName,
  VoltronArray array, {
  Promise? promise,
}) {
  if (viewModel == null) {
    return;
  }

  if (functionName == kFuncSetPage) {
    int? selected = array.get<int>(0);
    if (selected != null && selected >= 0 && selected < viewModel.children.length) {
      viewModel.pageController?.animateToPage(
        selected,
        duration: const Duration(milliseconds: 300),
        curve: Curves.linearToEaseOut,
      );
    }
  } else if (functionName == kFuncSetPageWidthOutAnim) {
    int? selected = array.get<int>(0);
    if (selected != null && selected >= 0 && selected < viewModel.children.length) {
      viewModel.pageController?.jumpToPage(
        selected,
      );
    }
  }
}