GridBuilder<T>.count constructor

const GridBuilder<T>.count({
  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. required List<T> source,
  10. required int crossAxisCount,
  11. required Widget builder(
    1. BuildContext context,
    2. T item,
    3. int index
    ),
  12. bool addAutomaticKeepAlives = true,
  13. bool addRepaintBoundaries = true,
  14. bool addSemanticIndexes = true,
  15. double? cacheExtent,
  16. int? semanticChildCount,
  17. bool listenWhenListenable = true,
  18. DragStartBehavior dragStartBehavior = DragStartBehavior.start,
  19. ScrollViewKeyboardDismissBehavior keyboardDismissBehavior = ScrollViewKeyboardDismissBehavior.manual,
  20. String? restorationId,
  21. Clip clipBehavior = Clip.hardEdge,
  22. double mainAxisSpacing = 0.0,
  23. double crossAxisSpacing = 0.0,
  24. double childAspectRatio = 1.0,
  25. double? mainAxisExtent,
})

Draw a grid list with elements generated from builder given source.

It is possible to configure the grid by specifying the number of horizontal pieces in crossAxisCount.

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から生成された要素でグリッドリストを描画します。

crossAxisCountで横の個数を指定してグリッドを構成することが可能です。

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

Implementation

const GridBuilder.count({
  super.key,
  this.scrollDirection = Axis.vertical,
  this.reverse = false,
  this.controller,
  this.primary,
  this.physics,
  this.shrinkWrap = false,
  this.padding,
  required this.source,
  required this.crossAxisCount,
  required this.builder,
  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,
  this.mainAxisSpacing = 0.0,
  this.crossAxisSpacing = 0.0,
  this.childAspectRatio = 1.0,
  this.mainAxisExtent,
})  : maxCrossAxisExtent = 0.0,
      assert(
        crossAxisCount > 0,
        "[crossAxisCount] must be greater than or equal to 0.",
      );