how to implement onOkPressed function?
Hanggi opened this issue · comments
The showTextInputDialog will return a String with closing the dialog.
I don't want to close the dialog, how could I finish the aysncronous validation when ok pressed?
This package has a policy of keeping features simple, and there are no plans to provide such features.
If you'd like to achieve an ideal specification that cannot be achieved with this package, please implement it on your own without using this package.
Alternatively, if you use this package, you can implement something like the following, where the dialog is closed and the obtained string is redisplayed if it failed to validate.
Future<bool> validate(String text) async {
return Future.value(false);
}
Future<void> showDialog([String? initialText]) async {
final texts = await showTextInputDialog(
context: context,
textFields: [
DialogTextField(initialText: initialText),
],
);
final text = texts?.first ?? '';
if (!await validate(text)) {
return showDialog(text);
}
logger.info('valid');
}
showDialog();