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;
  if (!EditorBloc.editMode) {
    selectFunction = Lowder.actions.getValueFunction(
        context, actions["onSelect"], state, evaluatorContext);
  }

  final axis = spec.buildProp("scrollDirection") ?? Axis.vertical;
  Widget? separatorWidget = Lowder.widgets
      .tryBuildWidget(context, widgets["separator"], state, null);

  return ListView(
    key: Key("${id}_list"),
    padding: Lowder.properties.getInsets(spec.props["padding"]),
    shrinkWrap: parseBool(props["shrinkWrap"]),
    reverse: parseBool(props["reverse"]),
    primary: tryParseBool(props["primary"]),
    controller: controller,
    scrollDirection: axis,
    semanticChildCount: count,
    keyboardDismissBehavior: spec.buildProp("keyboardDismissBehavior") ??
        ScrollViewKeyboardDismissBehavior.manual,
    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]),
        );
      }
      if (separatorWidget != null && i < count - 1) {
        final children = [itemWidget, separatorWidget];
        itemWidget = axis == Axis.vertical
            ? Column(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: children)
            : Row(children: children);
      }
      return itemWidget;
    }),
  );
}