getErrorText method

String? getErrorText(
  1. BlocXTextFieldOptions options
)

Returns the first bloc-driven error for this field, or falls back to BlocXTextFieldOptions.errorText.

Implementation

String? getErrorText(BlocXTextFieldOptions options) {
  final index = bloc.state.errors.keys.toList().indexWhere((e) => e == widget.formKey);
  if (index >= 0) {
    return bloc.state.errors.values.toList()[index].first;
  }
  return options.errorText;
}