build method

  1. @override
Widget build(
  1. BuildContext context,
  2. List<DropdownItem<T>> items,
  3. bool loading
)
override

Implementation

@override
Widget build(
    BuildContext context, List<DropdownItem<T>> items, bool loading) {
  final reversed = position.anchor.y > 0;

  Widget result;

  if (loading) {
    result = loadingBuilder?.call(context) ??
        const Center(
          child: CircularProgressIndicator(),
        );
  } else if (items.isEmpty) {
    result = emptyListBuilder?.call(context) ??
        const Center(
          child: Text("No items"),
        );
  } else {
    result = separatorBuilder != null
        ? ListView.separated(
            reverse: reversed,
            padding: EdgeInsets.zero,
            itemBuilder: (inner, index) => itemBuilder(context, items[index]),
            separatorBuilder: separatorBuilder!,
            itemCount: items.length,
          )
        : ListView.builder(
            reverse: reversed,
            padding: EdgeInsets.zero,
            itemCount: items.length,
            itemBuilder: (inner, index) => itemBuilder(context, items[index]),
          );
  }

  return result;
}