LayouterVisitorWithContext typedef
LayouterVisitorWithContext =
Size Function(BuildContext context, Layouter layouter)
Same as LayouterVisitor, but with context
This method accepts a layouter and returns the Size of the container of all widgets.
The layouter have access to some common data about the parent of the current widget after having laid them out individually. One can use those decision to make extra offsets based on the current ambient layout data such as the constriants, the screen width and height, or the siblings data.
This is similar to obtaining Widgets detail using GlobalKey, but instead of getting the layout details post-render, all details are obtained within the same frame.
The call order is childrenBuilder -> childrenConstrainer -> layouterVisitor
This means that you can use information the childrenBuilder have access to
in the visitor.
final List<int> nestedRowsAmount = [];
return FullPassBuilder(layouterVisitor: (context, layouter) {
// ...
return Size(...);
}, childrenBuilder: (context, constraints) {
final List<List<Widget>> widgets = obtainWidgetsFromSomewhere(context);
widgets.forEach((w) => nestedRowsAmount.add(w.length));
return [...];
});
Implementation
typedef LayouterVisitorWithContext = Size Function(
BuildContext context, Layouter layouter);