isSingleLine static method

bool isSingleLine([
  1. Finder? superTextFieldFinder
])

Returns true if the given SuperTextField is a single-line text field.

By default, this method expects a single SuperTextField in the widget tree and finds it byType. To specify one SuperTextField among many, pass a superTextFieldFinder.

Implementation

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

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

  switch (match.runtimeType) {
    case SuperDesktopTextField:
      return (match as SuperDesktopTextField).maxLines == 1;
    case SuperAndroidTextField:
      return (match as SuperAndroidTextField).maxLines == 1;
    case SuperIOSTextField:
      return (match as SuperIOSTextField).maxLines == 1;
    default:
      throw Exception("Found unknown SuperTextField platform widget: $match");
  }
}