selectSuperTextFieldText method

Future<void> selectSuperTextFieldText(
  1. int start,
  2. int end, [
  3. Finder? superTextFieldFinder
])

Implementation

Future<void> selectSuperTextFieldText(int start, int end, [Finder? superTextFieldFinder]) async {
  final fieldFinder =
      SuperTextFieldInspector.findInnerPlatformTextField(superTextFieldFinder ?? find.byType(SuperTextField));
  final match = fieldFinder.evaluate().single.widget;

  if (match is SuperDesktopTextField) {
    final didSelectText = await _selectTextOnDesktop(state<SuperDesktopTextFieldState>(fieldFinder), start, end);
    if (!didSelectText) {
      throw Exception("One or both of the desired text offsets weren't tappable in SuperTextField: $start -> $end");
    }

    // Pump and settle so that the gesture recognizer doesn't retain pending timers.
    await pumpAndSettle();

    return;
  }

  if (match is SuperAndroidTextField) {
    throw Exception("Selecting text on an Android SuperTextField is not yet supported");
  }

  if (match is SuperIOSTextField) {
    throw Exception("Selecting text on an iOS SuperTextField is not yet supported");
  }

  throw Exception("Couldn't find a SuperTextField with the given Finder: $fieldFinder");
}