PostFrameScrollBuilder class
A widget that provides post-frame callbacks with multiple scroll controller support.
This widget combines the functionality of PostFrameBuilder with PostFrameScrollManager to provide a convenient way to:
- Execute code after the first frame is rendered
- Manage multiple scroll controllers
- Access the widget's BuildContext and size
Example:
PostFrameScrollBuilder(
controllerKeys: ['list1', 'list2'],
onAfterBuildFrame: (data) {
// Access controllers
final controller1 = data.scrollManager['list1'];
// Get widget size
print('Size: ${data.size}');
// Scroll to position
data.scrollManager.animateTo('list1', 100,
duration: Duration(milliseconds: 300));
},
builder: (context, scrollManager) {
return Column(
children: [
Expanded(
child: ListView.builder(
controller: scrollManager['list1'],
itemBuilder: (context, index) => Text('Item $index'),
),
),
Expanded(
child: ListView.builder(
controller: scrollManager['list2'],
itemBuilder: (context, index) => Text('Item $index'),
),
),
],
);
},
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- PostFrameScrollBuilder
Constructors
-
PostFrameScrollBuilder({Key? key, List<
String> controllerKeys = const [], Map<String, double> ? initialScrollOffsets, FutureOr<void> onAfterBuildFrame(PostFrameScrollData data)?, required Widget builder(BuildContext context, PostFrameScrollManager scrollManager), void onScroll(String key, double offset)?}) -
const
Properties
- builder → Widget Function(BuildContext context, PostFrameScrollManager scrollManager)
-
Builder function that provides the scroll manager for building the UI.
final
-
controllerKeys
→ List<
String> -
List of controller keys to create automatically.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
initialScrollOffsets
→ Map<
String, double> ? -
Map of controller keys to their initial scroll offsets.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onAfterBuildFrame
→ FutureOr<
void> Function(PostFrameScrollData data)? -
Callback invoked after the first frame is rendered.
final
- onScroll → void Function(String key, double offset)?
-
Optional callback invoked when any scroll controller's position changes.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< PostFrameScrollBuilder> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited