ListViewModel.copy constructor

ListViewModel.copy(
  1. int id,
  2. int instanceId,
  3. String className,
  4. RenderContext<LoadInstanceContext> context,
  5. ListViewModel viewModel,
)

Implementation

ListViewModel.copy(
  int id,
  int instanceId,
  String className,
  RenderContext context,
  ListViewModel viewModel,
) : super.copy(id, instanceId, className, context, viewModel) {
  horizontal = viewModel.horizontal;
  bounces = viewModel.bounces;
  showScrollIndicator = viewModel.showScrollIndicator;
  hasStickyItem = viewModel.hasStickyItem;
  preloadSize = viewModel.preloadSize;
  initOffset = viewModel.initOffset;
  scrollGestureDispatcher = viewModel.scrollGestureDispatcher;
  paddingTop = viewModel.paddingTop;
  paddingRight = viewModel.paddingRight;
  paddingBottom = viewModel.paddingBottom;
  paddingLeft = viewModel.paddingLeft;
  var stickyList = <List<RenderViewModel>>[];
  var realItemList = <ListItemViewModel>[];
  var isSticky = false;
  if (viewModel.hasStickyItem) {
    if (viewModel.children.isNotEmpty) {
      var curList = <RenderViewModel>[];
      for (var element in viewModel.children) {
        if (element is ListItemViewModel) {
          if (element.shouldSticky) {
            // sticky item
            if (curList.isNotEmpty) {
              stickyList.add(curList);
              curList = <RenderViewModel>[];
            }
            stickyList.add([element]);
            isSticky = true;
          } else {
            curList.add(element);
          }
        }
      }
      if (curList.isNotEmpty) {
        stickyList.add(curList);
      }
    }
  }
  hasStickyItem = isSticky;
  if (!hasStickyItem) {
    realItemList = viewModel.children.whereType<ListItemViewModel>().toList();
  }
  listViewDetailModel = ListViewDetailModel(
    childrenList: viewModel.children,
    preloadSize: viewModel.preloadSize,
    controller: viewModel.scrollController,
    horizontal: viewModel.horizontal,
    bounces: viewModel.bounces,
    scrollGestureDispatcher: viewModel.scrollGestureDispatcher,
    refreshEventDispatcher: viewModel.refreshEventDispatcher,
    delegate: viewModel.refreshWrapper,
    showScrollIndicator: viewModel.showScrollIndicator,
    hasStickyItem: hasStickyItem,
    pullHeaderViewModel: viewModel.pullHeaderViewModel,
    pullFooterViewModel: viewModel.pullFooterViewModel,
    stickyList: stickyList,
    realItemList: realItemList,
    paddingTop: viewModel.paddingTop,
    paddingRight: viewModel.paddingRight,
    paddingBottom: viewModel.paddingBottom,
    paddingLeft: viewModel.paddingLeft,
    hasRemovePreDraw: viewModel.hasRemovePreDraw,
  );
}