ensureVisible method

void ensureVisible(
  1. GlobalKey<State<StatefulWidget>> key, {
  2. double alignment = 0.3,
  3. Duration? scrollDuration,
})

Brings view to the center of the screen

Implementation

// coverage:ignore-start
void ensureVisible(GlobalKey key,
    {double alignment = 0.3, Duration? scrollDuration}) async {
  try {
    await Scrollable.ensureVisible(
      key.currentContext!,
      duration: scrollDuration ?? UINavigationSettings.transitionDuration,
      alignment: alignment,
    );
  } catch (e) {
    // ignore
  }
}