From 171d178b09ce887a3b55e58df389174ca743b471 Mon Sep 17 00:00:00 2001 From: 21pages Date: Tue, 4 Mar 2025 14:11:18 +0800 Subject: [PATCH] make errorText of DialogTextField selectable (#11013) Signed-off-by: 21pages --- flutter/lib/common/widgets/dialog.dart | 50 ++++++++++++++++---------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/flutter/lib/common/widgets/dialog.dart b/flutter/lib/common/widgets/dialog.dart index 135d28c1d..345a140ad 100644 --- a/flutter/lib/common/widgets/dialog.dart +++ b/flutter/lib/common/widgets/dialog.dart @@ -412,24 +412,38 @@ class DialogTextField extends StatelessWidget { return Row( children: [ Expanded( - child: TextField( - decoration: InputDecoration( - labelText: title, - hintText: hintText, - prefixIcon: prefixIcon, - suffixIcon: suffixIcon, - helperText: helperText, - helperMaxLines: 8, - errorText: errorText, - errorMaxLines: 8, - ), - controller: controller, - focusNode: focusNode, - autofocus: true, - obscureText: obscureText, - keyboardType: keyboardType, - inputFormatters: inputFormatters, - maxLength: maxLength, + child: Column( + children: [ + TextField( + decoration: InputDecoration( + labelText: title, + hintText: hintText, + prefixIcon: prefixIcon, + suffixIcon: suffixIcon, + helperText: helperText, + helperMaxLines: 8, + ), + controller: controller, + focusNode: focusNode, + autofocus: true, + obscureText: obscureText, + keyboardType: keyboardType, + inputFormatters: inputFormatters, + maxLength: maxLength, + ), + if (errorText != null) + Align( + alignment: Alignment.centerLeft, + child: SelectableText( + errorText!, + style: TextStyle( + color: Theme.of(context).colorScheme.error, + fontSize: 12, + ), + textAlign: TextAlign.left, + ).paddingOnly(top: 8, left: 12), + ), + ], ).workaroundFreezeLinuxMint(), ), ],