findMaxScrollOffset static method

double? findMaxScrollOffset([
  1. Finder? superTextFieldFinder
])

Implementation

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

  final fieldFinder = findInnerPlatformTextField(finder);
  final match = fieldFinder.evaluate().single.widget;

  if (match is SuperDesktopTextField) {
    final textScrollViewElement = find
        .descendant(
          of: finder,
          matching: find.byType(SuperTextFieldScrollview),
        )
        .evaluate()
        .single as StatefulElement;
    final textScrollView = textScrollViewElement.widget as SuperTextFieldScrollview;

    return textScrollView.scrollController.position.maxScrollExtent;
  }

  // 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.endScrollOffset;
}