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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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