Skip to content

Commit 4468f11

Browse files
committed
fix(ArgsEditor): Add UniqueKey to manipulate
Flutter compares widgets only by Type and not state. Thus when the state is changed of the List represented in the List/GridView, Flutter doesn't know which children should be removed as their Types are still the same and checks out.
1 parent 50dde3a commit 4468f11

4 files changed

+34
-35
lines changed

lib/i18n/strings_en.i18n.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@
109109
"descriptionForRclone": "Edit startup arguments for rclone. You can also paste a full line, Alist Helper will help you parse it.",
110110
"editArguments": "Edit Arguments",
111111
"addArgument": "Add Argument",
112-
"removeAll":"Remove all"
112+
"removeAll":"Remove all",
113+
"remove":"Remove"
113114
},
114115
"proxy": {
115116
"title": "Http Proxy",

lib/i18n/strings_zh-Hans-CN.i18n.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@
110110
"descriptionForRclone": "编辑 rclone 的启动参数。你也可以粘贴整行,Alist Helper 会帮你解析。",
111111
"editArguments": "编辑参数",
112112
"addArgument": "添加参数",
113-
"removeAll": "移除所有参数"
113+
"removeAll": "移除所有参数",
114+
"remove":"移除参数"
114115
},
115116
"proxy": {
116117
"title": "Http 代理",

lib/i18n/strings_zh-Hant-TW.i18n.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@
110110
"descriptionForRclone": "編輯 rclone 的啟動參數。你也可以粘貼整行,Alist Helper 會幫你解析。",
111111
"editArguments": "編輯參數",
112112
"addArgument": "新增參數",
113-
"removeAll": "移除所有參數"
113+
"removeAll": "移除所有參數",
114+
"remove": "移除參數"
114115
},
115116
"proxy": {
116117
"title": "Http 代理",

lib/widgets/alist_args_tile.dart

+28-32
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class __AlistArgsDialogState extends State<_AlistArgsDialog> {
7575
children: [
7676
for (var i = 0; i < args.length; i++)
7777
Row(
78+
key: UniqueKey(),
7879
children: [
7980
Expanded(
8081
child: TextFormField(
@@ -88,19 +89,20 @@ class __AlistArgsDialogState extends State<_AlistArgsDialog> {
8889
args.removeAt(i);
8990
});
9091
},
92+
tooltip: t.settings.alistSettings.argumentsList.remove,
9193
icon: const Icon(Icons.delete_forever_rounded),
9294
),
95+
IconButton(
96+
onPressed: () {
97+
setState(() {
98+
args.insert(i + 1, '');
99+
});
100+
},
101+
tooltip: t.settings.alistSettings.argumentsList.addArgument,
102+
icon: const Icon(Icons.add_rounded),
103+
),
93104
],
94105
),
95-
Container(height: 20),
96-
ElevatedButton(
97-
onPressed: () {
98-
setState(() {
99-
args.add('');
100-
});
101-
},
102-
child: Text(t.settings.alistSettings.argumentsList.addArgument),
103-
),
104106
],
105107
),
106108
),
@@ -190,6 +192,7 @@ class __RcloneArgsDialogState extends State<_RcloneArgsDialog> {
190192
children: [
191193
for (var i = 0; i < args.length; i++)
192194
Row(
195+
key: UniqueKey(),
193196
children: [
194197
Expanded(
195198
child: TextFormField(
@@ -205,31 +208,16 @@ class __RcloneArgsDialogState extends State<_RcloneArgsDialog> {
205208
},
206209
icon: const Icon(Icons.delete_forever_rounded),
207210
),
211+
IconButton(
212+
onPressed: () {
213+
setState(() {
214+
args.insert(i, '');
215+
});
216+
},
217+
icon: const Icon(Icons.add_rounded),
218+
),
208219
],
209220
),
210-
Container(height: 20),
211-
Row(
212-
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
213-
children: [
214-
ElevatedButton(
215-
onPressed: () {
216-
setState(() {
217-
args = [];
218-
});
219-
},
220-
child: Text(t.settings.alistSettings.argumentsList.removeAll),
221-
),
222-
ElevatedButton(
223-
onPressed: () {
224-
setState(() {
225-
args.add('');
226-
});
227-
},
228-
child:
229-
Text(t.settings.alistSettings.argumentsList.addArgument),
230-
),
231-
],
232-
),
233221
],
234222
),
235223
),
@@ -238,6 +226,14 @@ class __RcloneArgsDialogState extends State<_RcloneArgsDialog> {
238226
onPressed: () => Navigator.of(context).pop(),
239227
child: Text(t.button.cancel),
240228
),
229+
TextButton(
230+
onPressed: () {
231+
setState(() {
232+
args = [];
233+
});
234+
},
235+
child: Text(t.settings.alistSettings.argumentsList.removeAll),
236+
),
241237
ElevatedButton(
242238
onPressed: () {
243239
if (args.length == 1 && args[0].contains(' ')) {

0 commit comments

Comments
 (0)