findMobileScrollController static method

TextScrollController? findMobileScrollController([
  1. Finder? superTextFieldFinder
])

Implementation

static TextScrollController? findMobileScrollController([Finder? superTextFieldFinder]) {
  final finder = superTextFieldFinder ?? find.byType(SuperTextField);

  final fieldFinder = findInnerPlatformTextField(finder);
  final match = fieldFinder.evaluate().single.widget;
  if (match is! SuperAndroidTextField && match is! SuperIOSTextField) {
    return null;
  }

  // Both mobile textfields use TextScrollView.
  final textScrollViewElement = find
      .descendant(
        of: finder,
        matching: find.byType(TextScrollView),
      )
      .evaluate()
      .single as StatefulElement;
  final textScrollView = textScrollViewElement.widget as TextScrollView;

  return textScrollView.textScrollController;
}