@@ -158,14 +158,7 @@ class _SubscriptionViewState extends State<SubscriptionView> {
158158 final ua = settings['ua' ];
159159 final id = DateTime .now ().millisecondsSinceEpoch.toString ();
160160 final downloadResult = await downloadYamlFile (result, ua,id);
161- Fluttertoast .showToast (
162- msg: "下载完成" ,
163- toastLength: Toast .LENGTH_SHORT , // 显示时长,SHORT 或 LONG
164- gravity: ToastGravity .BOTTOM , // 显示在屏幕底部
165- backgroundColor: Colors .black87, // 背景色
166- textColor: Colors .white, // 文字颜色
167- fontSize: 14.0 , // 文字大小
168- );
161+
169162 subscriptions.add (
170163 SubscriptionInfo (
171164 id: downloadResult.id,
@@ -177,29 +170,15 @@ class _SubscriptionViewState extends State<SubscriptionView> {
177170 expire: downloadResult.expire,
178171 ),
179172 );
180-
181173 final data = {
182174 'subscriptions' : subscriptions.map ((s) => s.toMap ()).toList (),
183175 };
184-
185176 await writeYamlFromObject (data, subscriptionsPath);
186- Fluttertoast .showToast (
187- msg: "更新完成" ,
188- toastLength: Toast .LENGTH_SHORT , // 显示时长,SHORT 或 LONG
189- gravity: ToastGravity .BOTTOM , // 显示在屏幕底部
190- backgroundColor: Colors .black87, // 背景色
191- textColor: Colors .white, // 文字颜色
192- fontSize: 14.0 , // 文字大小
193- );
194-
195177 setState (() {});
196- close ();
197178 } catch (e) {
198- close ();
199179 if (! mounted) return ;
200180 await showErrorDialog (context, '加载错误' , e);
201-
202- }
181+ } finally {if (mounted) close ();}
203182 }
204183
205184 @override
0 commit comments