onScrollTo method

dynamic onScrollTo(
  1. Event event
)

Takes an event (onscroll) and uses the id to scroll to that widget

Implementation

onScrollTo(Event event) {
  // BuildContext context;
  event.handled = true;
  if (event.parameters!.containsKey('id')) {
    String? id = event.parameters!['id'];
    var child = widget.model.findDescendantOfExactType(null, id: id);

    // if there is an error with this, we need to check _controller.hasClients as it must not be false when using [ScrollPosition],such as [position], [offset], [animateTo], and [jumpTo],
    if ((child != null) && (child.context != null)) {
      Scrollable.ensureVisible(child.context,
          duration: const Duration(seconds: 1), alignment: 0.2);
    }
  }
}