scrollTo method
scroll to specified item by id and value
Implementation
@override
void scrollTo(String? id, String? value, {bool animate = false}) {
if (id == null) return;
// get the view
ScrollerViewState? view = findListenerOfExactType(ScrollerViewState);
// scroll to top
if (id.trim().toLowerCase() == 'top' && isNullOrEmpty(value)) {
view?.scrollTo(0, animate: false);
return;
}
// scroll to bottom
if (id.trim().toLowerCase() == 'bottom' && isNullOrEmpty(value)) {
view?.scrollTo(double.maxFinite, animate: false);
return;
}
// scroll to specific pixel position
if (isNumeric(id) && isNullOrEmpty(value)) {
view?.scrollTo(toDouble(id), animate: false);
}
// find the first child with the specified
// id and matching value
var child = descendants?.toList().firstWhereOrNull((child) => child.id == id && child.value == (value ?? child.value));
if (child != null) {
view?.scrollToContext(child.context, animate: animate);
}
}