ListBuilder<T> constructor

const ListBuilder<T>({
  1. Key? key,
  2. Axis scrollDirection = Axis.vertical,
  3. bool reverse = false,
  4. ScrollController? controller,
  5. bool? primary,
  6. ScrollPhysics? physics,
  7. bool shrinkWrap = false,
  8. EdgeInsetsGeometry? padding,
  9. List<Widget>? top,
  10. List<Widget>? insert,
  11. int insertPosition = 0,
  12. List<Widget>? bottom,
  13. double? itemExtent,
  14. required ListBuilderCallback<T> builder,
  15. required List<T> source,
  16. bool addAutomaticKeepAlives = true,
  17. bool addRepaintBoundaries = true,
  18. bool addSemanticIndexes = true,
  19. double? cacheExtent,
  20. int? semanticChildCount,
  21. bool listenWhenListenable = true,
  22. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  23. ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  24. String? restorationId,
  25. Clip clipBehavior = Clip.hardEdge,
})

If source is given, each of its elements is displayed side by side in builder.

If top is set, the top elements are lined up before the source elements are lined up.

If bottom is set, the elements of bottom are lined up after the elements of source are lined up.

When insert is set, insert is inserted at the position of insertPosition in source.

If listenWhenListenable is true, ListenableListener will be wrapped around each element if source inherits Listenable. Therefore, each element of source is monitored individually, and if any element is updated, only that element is updated in the drawing.

sourceを与えるとその各要素をbuilderで並べて表示します。

topを設定するとsourceの要素を並べる前にtopの要素を並べます。

bottomを設定するとsourceの要素を並べた後にbottomの要素を並べます。

insertを設定するとsourceinsertPositionの位置にinsertが挿入されます。

listenWhenListenabletrueになっている場合、sourceListenableを継承している場合ListenableListenerが各要素にラップされます。 そのため、sourceの各要素をそれぞれ監視し、いずれかの要素が更新された場合その要素のみ描画が更新されます。

Implementation

const ListBuilder({
  super.key,
  this.scrollDirection = Axis.vertical,
  this.reverse = false,
  this.controller,
  this.primary,
  this.physics,
  this.shrinkWrap = false,
  this.padding,
  this.top,
  this.insert,
  this.insertPosition = 0,
  this.bottom,
  this.itemExtent,
  required this.builder,
  required this.source,
  this.addAutomaticKeepAlives = true,
  this.addRepaintBoundaries = true,
  this.addSemanticIndexes = true,
  this.cacheExtent,
  this.semanticChildCount,
  this.listenWhenListenable = true,
  this.dragStartBehavior = DragStartBehavior.start,
  this.keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  this.restorationId,
  this.clipBehavior = Clip.hardEdge,
})  : _topLength = top.length,
      _length = top.length + source.length + bottom.length + insert.length,
      _topSourcelength = top.length + source.length + insert.length;