input method

Future<String?> input(
  1. HareEdit edit, {
  2. required String title,
  3. String? message,
  4. TextValidator? validator,
  5. double spacing = 8,
})

Implementation

Future<String?> input(HareEdit edit, {required String title, String? message, TextValidator? validator, double spacing = 8}) async {
  GlobalKey<FormState> formKey = GlobalKey();
  return showColumn(
    onContent: (uc) {
      uc.onValidate = () {
        if (formKey.currentState?.validate() != true) return false;
        if (!edit.validate(validator)) return false;
        String s = edit.value;
        uc.setResult(s);
        return true;
      };
      return Form(
        key: formKey,
        child: ColumnMinStretch([if (message != null) messageWidget(message), edit], spacing: spacing),
      );
    },
    title: title,
    ok: true,
    cancel: true,
  );
}