buildList method

  1. @override
Widget buildList(
  1. BuildContext context
)
override

Implementation

@override
Widget buildList(BuildContext context) {
  var count = mutable.lastState.fullData.length;
  if (mutable.lastState.hasMore) count++;

  Function? selectFunction;
  Function? pageChangeFunction;
  if (!EditorBloc.editMode) {
    selectFunction = Lowder.actions.getValueFunction(
        context, actions["onSelect"], state, evaluatorContext);
    pageChangeFunction = Lowder.actions.getValueFunction<int?>(
        context, actions["onPageChanged"], state, evaluatorContext);
  }

  return PageView(
    key: Key("${id}_list"),
    pageSnapping: parseBool(props["pageSnapping"], defaultValue: true),
    padEnds: parseBool(props["padEnds"], defaultValue: true),
    scrollDirection: spec.buildProp("scrollDirection") ?? Axis.horizontal,
    reverse: parseBool(props["reverse"]),
    controller: pageController,
    onPageChanged: (idx) {
      onPageChanged(idx, count);
      if (pageChangeFunction != null) {
        pageChangeFunction(idx);
      }
    },
    children: List.generate(count, (i) {
      if (mutable.lastState.hasMore && i == count - 1) {
        return getLoadingIndicator();
      }

      var itemWidget = buildWidget(context, childSpec!, i);
      if (selectFunction != null) {
        itemWidget = InkWell(
          child: itemWidget,
          onTap: () => selectFunction!(mutable.lastState.fullData[i]),
        );
      }
      return itemWidget;
    }),
  );
}