inputText static method
Future<String?>
inputText({
- String? value,
- required String title,
- String? label,
- String? message,
- String? tips,
- RegExp? allowExp,
- RegExp? denyExp,
- TextInputType? keyboardType,
- List<
TextInputFormatter> ? inputFormaters, - TextValidator? validator,
- int? maxLines = 1,
- int minLength = 1,
- int maxLength = 255,
- bool allowEmpty = false,
- bool trim = false,
- bool? password,
- DialogWidth? width,
Implementation
static Future<String?> inputText({
String? value,
required String title,
String? label,
String? message,
String? tips,
RegExp? allowExp,
RegExp? denyExp,
TextInputType? keyboardType,
List<TextInputFormatter>? inputFormaters,
TextValidator? validator,
int? maxLines = 1,
int minLength = 1,
int maxLength = 255,
bool allowEmpty = false,
bool trim = false,
bool? password,
DialogWidth? width,
}) {
TextValidator lenValid = Valids.length(minLength, maxLength, allowEmpty: allowEmpty, trim: trim);
TextValidator vs = validator == null ? lenValid : Valids.list([validator, lenValid]);
return showDialogX((b) {
if (width != null) b.dialogWidth = width;
b.title(title.text());
bool multiLines = maxLines != null && maxLines > 1;
ListWidget ls = [];
HareEdit edit = HareEdit(
value: value?.toString() ?? "",
helpText: tips,
label: label,
allowExp: allowExp,
denyExp: denyExp,
keyboardType: keyboardType,
inputFormaters: inputFormaters,
validator: vs,
maxLength: maxLength,
maxLines: maxLines,
password: password,
autofucus: true,
noClear: multiLines,
border: !multiLines ? null : OutlineInputBorder(),
onSubmit: (s) {
b.setResult(s);
b.clickOK();
});
ls << edit;
if (multiLines) {
Widget btn = b.makeAction("清除", () {
edit.value = "";
});
b.actions(ok: true, cancel: true, items: [btn]);
} else {
b.actions(ok: true, cancel: true);
}
b.okCallback = () {
if (!edit.validate()) return false;
String s = trim ? edit.value.trim() : edit.value;
b.setResult(s);
return true;
};
return b.buildColumn(ls, message: message);
});
}