fix: linux, flutter, workaround freeze (#10324)

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2024-12-20 09:24:08 +08:00
committed by GitHub
parent 7830a9e9f3
commit 9114743577
18 changed files with 95 additions and 79 deletions

View File

@@ -3625,3 +3625,16 @@ void checkUpdate() {
} }
} }
} }
// https://github.com/flutter/flutter/issues/153560#issuecomment-2497160535
// For TextField, TextFormField
extension WorkaroundFreezeLinuxMint on Widget {
Widget workaroundFreezeLinuxMint() {
// No need to check if is Linux Mint, because this workaround is harmless on other platforms.
if (isLinux) {
return ExcludeSemantics(child: this);
} else {
return this;
}
}
}

View File

@@ -286,7 +286,7 @@ class _AddressBookState extends State<AddressBook> {
borderRadius: BorderRadius.circular(8), borderRadius: BorderRadius.circular(8),
), ),
), ),
), ).workaroundFreezeLinuxMint(),
), ),
searchMatchFn: (item, searchValue) { searchMatchFn: (item, searchValue) {
return item.value return item.value
@@ -556,7 +556,7 @@ class _AddressBookState extends State<AddressBook> {
: translate('ID'), : translate('ID'),
errorText: errorMsg, errorText: errorMsg,
errorMaxLines: 5), errorMaxLines: 5),
))), ).workaroundFreezeLinuxMint())),
row( row(
lable: Text( lable: Text(
translate('Alias'), translate('Alias'),
@@ -569,7 +569,7 @@ class _AddressBookState extends State<AddressBook> {
? null ? null
: translate('Alias'), : translate('Alias'),
), ),
)), ).workaroundFreezeLinuxMint()),
), ),
if (isCurrentAbShared) if (isCurrentAbShared)
row( row(
@@ -598,7 +598,7 @@ class _AddressBookState extends State<AddressBook> {
}, },
), ),
), ),
), ).workaroundFreezeLinuxMint(),
)), )),
if (gFFI.abModel.currentAbTags.isNotEmpty) if (gFFI.abModel.currentAbTags.isNotEmpty)
Align( Align(
@@ -704,7 +704,7 @@ class _AddressBookState extends State<AddressBook> {
), ),
controller: controller, controller: controller,
autofocus: true, autofocus: true,
), ).workaroundFreezeLinuxMint(),
), ),
], ],
), ),

View File

@@ -167,7 +167,7 @@ class ChatPage extends StatelessWidget implements PageShape {
); );
}, },
), ),
); ).workaroundFreezeLinuxMint();
return SelectionArea(child: chat); return SelectionArea(child: chat);
}), }),
], ],

View File

@@ -140,7 +140,7 @@ void changeIdDialog() {
msg = ''; msg = '';
}); });
}, },
), ).workaroundFreezeLinuxMint(),
const SizedBox( const SizedBox(
height: 8.0, height: 8.0,
), ),
@@ -201,13 +201,14 @@ void changeWhiteList({Function()? callback}) async {
children: [ children: [
Expanded( Expanded(
child: TextField( child: TextField(
maxLines: null, maxLines: null,
decoration: InputDecoration( decoration: InputDecoration(
errorText: msg.isEmpty ? null : translate(msg), errorText: msg.isEmpty ? null : translate(msg),
), ),
controller: controller, controller: controller,
enabled: !isOptFixed, enabled: !isOptFixed,
autofocus: true), autofocus: true)
.workaroundFreezeLinuxMint(),
), ),
], ],
), ),
@@ -287,22 +288,23 @@ Future<String> changeDirectAccessPort(
children: [ children: [
Expanded( Expanded(
child: TextField( child: TextField(
maxLines: null, maxLines: null,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
decoration: InputDecoration( decoration: InputDecoration(
hintText: '21118', hintText: '21118',
isCollapsed: true, isCollapsed: true,
prefix: Text('$currentIP : '), prefix: Text('$currentIP : '),
suffix: IconButton( suffix: IconButton(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
icon: const Icon(Icons.clear, size: 16), icon: const Icon(Icons.clear, size: 16),
onPressed: () => controller.clear())), onPressed: () => controller.clear())),
inputFormatters: [ inputFormatters: [
FilteringTextInputFormatter.allow(RegExp( FilteringTextInputFormatter.allow(RegExp(
r'^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$')), r'^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$')),
], ],
controller: controller, controller: controller,
autofocus: true), autofocus: true)
.workaroundFreezeLinuxMint(),
), ),
], ],
), ),
@@ -335,21 +337,22 @@ Future<String> changeAutoDisconnectTimeout(String old) async {
children: [ children: [
Expanded( Expanded(
child: TextField( child: TextField(
maxLines: null, maxLines: null,
keyboardType: TextInputType.number, keyboardType: TextInputType.number,
decoration: InputDecoration( decoration: InputDecoration(
hintText: '10', hintText: '10',
isCollapsed: true, isCollapsed: true,
suffix: IconButton( suffix: IconButton(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
icon: const Icon(Icons.clear, size: 16), icon: const Icon(Icons.clear, size: 16),
onPressed: () => controller.clear())), onPressed: () => controller.clear())),
inputFormatters: [ inputFormatters: [
FilteringTextInputFormatter.allow(RegExp( FilteringTextInputFormatter.allow(RegExp(
r'^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$')), r'^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$')),
], ],
controller: controller, controller: controller,
autofocus: true), autofocus: true)
.workaroundFreezeLinuxMint(),
), ),
], ],
), ),
@@ -427,7 +430,7 @@ class DialogTextField extends StatelessWidget {
keyboardType: keyboardType, keyboardType: keyboardType,
inputFormatters: inputFormatters, inputFormatters: inputFormatters,
maxLength: maxLength, maxLength: maxLength,
), ).workaroundFreezeLinuxMint(),
), ),
], ],
).paddingSymmetric(vertical: 4.0); ).paddingSymmetric(vertical: 4.0);
@@ -1501,7 +1504,7 @@ showAuditDialog(FFI ffi) async {
maxLength: 256, maxLength: 256,
controller: controller, controller: controller,
focusNode: focusNode, focusNode: focusNode,
)), ).workaroundFreezeLinuxMint()),
actions: [ actions: [
dialogButton('Cancel', onPressed: close, isOutline: true), dialogButton('Cancel', onPressed: close, isOutline: true),
dialogButton('OK', onPressed: submit) dialogButton('OK', onPressed: submit)
@@ -1748,7 +1751,7 @@ void renameDialog(
autofocus: true, autofocus: true,
decoration: InputDecoration(labelText: translate('Name')), decoration: InputDecoration(labelText: translate('Name')),
validator: validator, validator: validator,
), ).workaroundFreezeLinuxMint(),
), ),
), ),
// NOT use Offstage to wrap LinearProgressIndicator // NOT use Offstage to wrap LinearProgressIndicator
@@ -1808,7 +1811,7 @@ void changeBot({Function()? callback}) async {
decoration: InputDecoration( decoration: InputDecoration(
hintText: translate('Token'), hintText: translate('Token'),
), ),
); ).workaroundFreezeLinuxMint();
return CustomAlertDialog( return CustomAlertDialog(
title: Text(translate("Telegram bot")), title: Text(translate("Telegram bot")),
@@ -2178,7 +2181,7 @@ void setSharedAbPasswordDialog(String abName, Peer peer) {
}, },
), ),
), ),
), ).workaroundFreezeLinuxMint(),
if (!gFFI.abModel.current.isPersonal()) if (!gFFI.abModel.current.isPersonal())
Row(children: [ Row(children: [
Icon(Icons.info, color: Colors.amber).marginOnly(right: 4), Icon(Icons.info, color: Colors.amber).marginOnly(right: 4),

View File

@@ -678,7 +678,7 @@ Future<bool?> verificationCodeDialog(
labelText: "Email", prefixIcon: Icon(Icons.email)), labelText: "Email", prefixIcon: Icon(Icons.email)),
readOnly: true, readOnly: true,
controller: TextEditingController(text: user?.email), controller: TextEditingController(text: user?.email),
)), ).workaroundFreezeLinuxMint()),
isEmailVerification ? const SizedBox(height: 8) : const Offstage(), isEmailVerification ? const SizedBox(height: 8) : const Offstage(),
codeField, codeField,
/* /*

View File

@@ -145,7 +145,7 @@ class _MyGroupState extends State<MyGroup> {
border: InputBorder.none, border: InputBorder.none,
isDense: true, isDense: true,
), ),
)), ).workaroundFreezeLinuxMint()),
], ],
); );
} }

View File

@@ -1257,7 +1257,7 @@ void _rdpDialog(String id) async {
hintText: '3389'), hintText: '3389'),
controller: portController, controller: portController,
autofocus: true, autofocus: true,
), ).workaroundFreezeLinuxMint(),
), ),
], ],
).marginOnly(bottom: isDesktop ? 8 : 0), ).marginOnly(bottom: isDesktop ? 8 : 0),
@@ -1277,7 +1277,7 @@ void _rdpDialog(String id) async {
labelText: labelText:
isDesktop ? null : translate('Username')), isDesktop ? null : translate('Username')),
controller: userController, controller: userController,
), ).workaroundFreezeLinuxMint(),
), ),
], ],
).marginOnly(bottom: stateGlobal.isPortrait.isFalse ? 8 : 0)), ).marginOnly(bottom: stateGlobal.isPortrait.isFalse ? 8 : 0)),
@@ -1305,7 +1305,7 @@ void _rdpDialog(String id) async {
? Icons.visibility_off ? Icons.visibility_off
: Icons.visibility))), : Icons.visibility))),
controller: passwordController, controller: passwordController,
)), ).workaroundFreezeLinuxMint()),
), ),
], ],
)) ))

View File

@@ -743,7 +743,7 @@ class _PeerSearchBarState extends State<PeerSearchBar> {
border: InputBorder.none, border: InputBorder.none,
isDense: true, isDense: true,
), ),
), ).workaroundFreezeLinuxMint(),
), ),
// Icon(Icons.close), // Icon(Icons.close),
IconButton( IconButton(

View File

@@ -424,7 +424,7 @@ class _ConnectionPageState extends State<ConnectionPage>
onSubmitted: (_) { onSubmitted: (_) {
onConnect(); onConnect();
}, },
)); ).workaroundFreezeLinuxMint());
}, },
onSelected: (option) { onSelected: (option) {
setState(() { setState(() {

View File

@@ -237,7 +237,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
style: TextStyle( style: TextStyle(
fontSize: 22, fontSize: 22,
), ),
), ).workaroundFreezeLinuxMint(),
), ),
) )
], ],
@@ -333,7 +333,7 @@ class _DesktopHomePageState extends State<DesktopHomePage>
EdgeInsets.only(top: 14, bottom: 10), EdgeInsets.only(top: 14, bottom: 10),
), ),
style: TextStyle(fontSize: 15), style: TextStyle(fontSize: 15),
), ).workaroundFreezeLinuxMint(),
), ),
), ),
if (showOneTime) if (showOneTime)
@@ -940,7 +940,7 @@ void setPasswordDialog({VoidCallback? notEmptyCallback}) async {
}); });
}, },
maxLength: maxLength, maxLength: maxLength,
), ).workaroundFreezeLinuxMint(),
), ),
], ],
), ),
@@ -967,7 +967,7 @@ void setPasswordDialog({VoidCallback? notEmptyCallback}) async {
}); });
}, },
maxLength: maxLength, maxLength: maxLength,
), ).workaroundFreezeLinuxMint(),
), ),
], ],
), ),

View File

@@ -1189,7 +1189,7 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
contentPadding: contentPadding:
EdgeInsets.symmetric(vertical: 12, horizontal: 12), EdgeInsets.symmetric(vertical: 12, horizontal: 12),
), ),
).marginOnly(right: 15), ).workaroundFreezeLinuxMint().marginOnly(right: 15),
), ),
Obx(() => ElevatedButton( Obx(() => ElevatedButton(
onPressed: applyEnabled.value && onPressed: applyEnabled.value &&
@@ -1346,7 +1346,7 @@ class _SafetyState extends State<_Safety> with AutomaticKeepAliveClientMixin {
contentPadding: contentPadding:
EdgeInsets.symmetric(vertical: 12, horizontal: 12), EdgeInsets.symmetric(vertical: 12, horizontal: 12),
), ),
).marginOnly(right: 15), ).workaroundFreezeLinuxMint().marginOnly(right: 15),
), ),
Obx(() => ElevatedButton( Obx(() => ElevatedButton(
onPressed: onPressed:
@@ -2312,7 +2312,7 @@ _LabeledTextField(
style: TextStyle( style: TextStyle(
color: disabledTextColor(context, enabled), color: disabledTextColor(context, enabled),
), ),
), ).workaroundFreezeLinuxMint(),
], ],
), ),
], ],
@@ -2491,7 +2491,7 @@ void changeSocks5Proxy() async {
controller: proxyController, controller: proxyController,
autofocus: true, autofocus: true,
enabled: !isOptFixed, enabled: !isOptFixed,
), ).workaroundFreezeLinuxMint(),
), ),
], ],
).marginOnly(bottom: 8), ).marginOnly(bottom: 8),
@@ -2511,7 +2511,7 @@ void changeSocks5Proxy() async {
labelText: isMobile ? translate('Username') : null, labelText: isMobile ? translate('Username') : null,
), ),
enabled: !isOptFixed, enabled: !isOptFixed,
), ).workaroundFreezeLinuxMint(),
), ),
], ],
).marginOnly(bottom: 8), ).marginOnly(bottom: 8),
@@ -2537,7 +2537,7 @@ void changeSocks5Proxy() async {
controller: pwdController, controller: pwdController,
enabled: !isOptFixed, enabled: !isOptFixed,
maxLength: bind.mainMaxEncryptLen(), maxLength: bind.mainMaxEncryptLen(),
)), ).workaroundFreezeLinuxMint()),
), ),
], ],
), ),

View File

@@ -768,7 +768,7 @@ class _FileManagerViewState extends State<FileManagerView> {
), ),
controller: name, controller: name,
autofocus: true, autofocus: true,
), ).workaroundFreezeLinuxMint(),
], ],
), ),
actions: [ actions: [
@@ -1657,7 +1657,7 @@ class _FileManagerViewState extends State<FileManagerView> {
onChanged: _locationStatus.value == LocationStatus.fileSearchBar onChanged: _locationStatus.value == LocationStatus.fileSearchBar
? (searchText) => onSearchText(searchText, isLocal) ? (searchText) => onSearchText(searchText, isLocal)
: null, : null,
), ).workaroundFreezeLinuxMint(),
) )
], ],
); );

View File

@@ -147,7 +147,7 @@ class _InstallPageBodyState extends State<_InstallPageBody>
decoration: InputDecoration( decoration: InputDecoration(
contentPadding: EdgeInsets.all(0.75 * em), contentPadding: EdgeInsets.all(0.75 * em),
), ),
).marginOnly(right: 10), ).workaroundFreezeLinuxMint().marginOnly(right: 10),
), ),
Obx( Obx(
() => OutlinedButton.icon( () => OutlinedButton.icon(

View File

@@ -238,7 +238,7 @@ class _PortForwardPageState extends State<PortForwardPage>
inputFormatters: inputFormatters, inputFormatters: inputFormatters,
decoration: InputDecoration( decoration: InputDecoration(
hintText: hint, hintText: hint,
))), )).workaroundFreezeLinuxMint()),
); );
} }

View File

@@ -1495,7 +1495,7 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
); );
} }
TextField _resolutionInput(TextEditingController controller) { Widget _resolutionInput(TextEditingController controller) {
return TextField( return TextField(
decoration: InputDecoration( decoration: InputDecoration(
border: InputBorder.none, border: InputBorder.none,
@@ -1509,7 +1509,7 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
FilteringTextInputFormatter.allow(RegExp(r'[0-9]')), FilteringTextInputFormatter.allow(RegExp(r'[0-9]')),
], ],
controller: controller, controller: controller,
); ).workaroundFreezeLinuxMint();
} }
List<Widget> _supportedResolutionMenuButtons() => resolutions List<Widget> _supportedResolutionMenuButtons() => resolutions

View File

@@ -225,7 +225,7 @@ class _FileManagerPageState extends State<FileManagerPage> {
errorText: errorText, errorText: errorText,
), ),
controller: name, controller: name,
), ).workaroundFreezeLinuxMint(),
], ],
), ),
actions: [ actions: [

View File

@@ -604,7 +604,7 @@ class _RemotePageState extends State<RemotePage> with WidgetsBindingObserver {
// ko/zh/ja input method: the button will trigger `onKeyEvent` // ko/zh/ja input method: the button will trigger `onKeyEvent`
// and the event will not popup if `KeyEventResult.handled` is returned. // and the event will not popup if `KeyEventResult.handled` is returned.
onChanged: handleSoftKeyboardInput, onChanged: handleSoftKeyboardInput,
), ).workaroundFreezeLinuxMint(),
), ),
]; ];
if (showCursorPaint) { if (showCursorPaint) {

View File

@@ -66,7 +66,7 @@ void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
? null ? null
: translate('Too short, at least 6 characters.'); : translate('Too short, at least 6 characters.');
}, },
), ).workaroundFreezeLinuxMint(),
TextFormField( TextFormField(
obscureText: true, obscureText: true,
keyboardType: TextInputType.visiblePassword, keyboardType: TextInputType.visiblePassword,
@@ -85,7 +85,7 @@ void setPermanentPasswordDialog(OverlayDialogManager dialogManager) async {
? null ? null
: translate('The confirmation is not identical.'); : translate('The confirmation is not identical.');
}, },
), ).workaroundFreezeLinuxMint(),
])), ])),
onCancel: close, onCancel: close,
onSubmit: (validateLength && validateSame) ? submit : null, onSubmit: (validateLength && validateSame) ? submit : null,
@@ -216,7 +216,7 @@ void showServerSettingsWithValue(
), ),
validator: validator, validator: validator,
autofocus: autofocus, autofocus: autofocus,
), ).workaroundFreezeLinuxMint(),
), ),
], ],
); );
@@ -229,7 +229,7 @@ void showServerSettingsWithValue(
errorText: errorMsg.isEmpty ? null : errorMsg, errorText: errorMsg.isEmpty ? null : errorMsg,
), ),
validator: validator, validator: validator,
); ).workaroundFreezeLinuxMint();
} }
return CustomAlertDialog( return CustomAlertDialog(