fix: make text dialog autosubmit work as expected (#1918)

This commit is contained in:
ggurdin 2025-02-25 13:50:35 -05:00 committed by GitHub
parent becd9d7395
commit ea9142b552
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -63,19 +63,11 @@ Future<String?> showTextInputDialog({
return TextField(
controller: controller,
obscureText: obscureText,
minLines: minLines,
maxLines: maxLines,
maxLength: maxLength,
keyboardType: keyboardType,
autocorrect: autocorrect,
decoration: InputDecoration(
errorText: error,
hintText: hintText,
labelText: labelText,
prefixText: prefixText,
suffixText: suffixText,
),
// #Pangea
// minLines: minLines,
// maxLines: maxLines,
minLines: autoSubmit ? 1 : minLines,
maxLines: autoSubmit ? 1 : maxLines,
onSubmitted: autoSubmit
? (_) {
final input = controller.text;
@ -88,6 +80,16 @@ Future<String?> showTextInputDialog({
}
: null,
// Pangea#
maxLength: maxLength,
keyboardType: keyboardType,
autocorrect: autocorrect,
decoration: InputDecoration(
errorText: error,
hintText: hintText,
labelText: labelText,
prefixText: prefixText,
suffixText: suffixText,
),
);
case TargetPlatform.iOS:
case TargetPlatform.macOS:
@ -97,8 +99,23 @@ Future<String?> showTextInputDialog({
CupertinoTextField(
controller: controller,
obscureText: obscureText,
minLines: minLines,
maxLines: maxLines,
// #Pangea
// minLines: minLines,
// maxLines: maxLines,
minLines: autoSubmit ? 1 : minLines,
maxLines: autoSubmit ? 1 : maxLines,
onSubmitted: autoSubmit
? (_) {
final input = controller.text;
final errorText = validator?.call(input);
if (errorText != null) {
error = errorText;
return;
}
Navigator.of(context).pop<String>(input);
}
: null,
// Pangea#
maxLength: maxLength,
keyboardType: keyboardType,
autocorrect: autocorrect,
@ -110,7 +127,7 @@ Future<String?> showTextInputDialog({
),
if (error != null)
Text(
error,
error!,
style: TextStyle(
fontSize: 11,
color: theme.colorScheme.error,