LifeMate — Personal, Family & Learning Companion
fix: enforce analyzer control-flow style
davoodmehraban89 committed
Oct 5, 2026 at 08:00 UTC
3a978a4373b1a432044bdb3871b938ec5290f0ad
1 file changed
+72
-24
apps/lifemate/lib/main.dart
+72
-24
@@ -99,14 +99,20 @@ class _SignInPageState extends State<SignInPage> {
99
if (widget.invitationToken != null) {
100
await widget.api.acceptInvitation(widget.invitationToken!);
101
}
102
- if (!mounted) return;
102
+ if (!mounted) {
103
+ return;
104
+ }
105
Navigator.of(context).pushReplacement(
106
MaterialPageRoute(builder: (_) => HomeShell(api: widget.api)),
107
);
108
} catch (e) {
107
- if (mounted) setState(() => error = errorText(e));
109
+ if (mounted) {
110
+ setState(() => error = errorText(e));
111
+ }
112
} finally {
109
- if (mounted) setState(() => busy = false);
113
+ if (mounted) {
114
+ setState(() => busy = false);
115
+ }
116
}
117
}
118
@@ -249,13 +255,19 @@ class _RegistrationPageState extends State<RegistrationPage> {
255
setState(() { busy = true; error = null; });
256
try {
257
await widget.api.register(displayName: name.text, email: email.text, password: password.text);
252
- if (!mounted) return;
258
+ if (!mounted) {
259
+ return;
260
+ }
261
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('حساب ساخته شد. ایمیل تأیید را بررسی کن.')));
262
Navigator.pop(context);
263
} catch (e) {
256
- if (mounted) setState(() => error = errorText(e));
264
+ if (mounted) {
265
+ setState(() => error = errorText(e));
266
+ }
267
} finally {
258
- if (mounted) setState(() => busy = false);
268
+ if (mounted) {
269
+ setState(() => busy = false);
270
+ }
271
}
272
}
273
@@ -292,11 +304,17 @@ class _RecoveryPageState extends State<RecoveryPage> {
304
setState(() { busy = true; error = null; });
305
try {
306
await widget.api.forgotPassword(email.text);
295
- if (mounted) setState(() => sent = true);
307
+ if (mounted) {
308
+ setState(() => sent = true);
309
+ }
310
} catch (e) {
297
- if (mounted) setState(() => error = errorText(e));
311
+ if (mounted) {
312
+ setState(() => error = errorText(e));
313
+ }
314
} finally {
299
- if (mounted) setState(() => busy = false);
315
+ if (mounted) {
316
+ setState(() => busy = false);
317
+ }
318
}
319
}
320
@@ -330,9 +348,13 @@ class _VerifyEmailPageState extends State<VerifyEmailPage> {
348
Future<void> verify() async {
349
try {
350
await widget.api.verifyEmail(widget.token);
333
- if (mounted) setState(() => message = 'ایمیل با موفقیت تأیید شد.');
351
+ if (mounted) {
352
+ setState(() => message = 'ایمیل با موفقیت تأیید شد.');
353
+ }
354
} catch (e) {
335
- if (mounted) setState(() => message = errorText(e));
355
+ if (mounted) {
356
+ setState(() => message = errorText(e));
357
+ }
358
}
359
}
360
@@ -363,11 +385,17 @@ class _ResetPasswordPageState extends State<ResetPasswordPage> {
385
setState(() { busy = true; error = null; });
386
try {
387
await widget.api.resetPassword(widget.token, password.text);
366
- if (mounted) setState(() => done = true);
388
+ if (mounted) {
389
+ setState(() => done = true);
390
+ }
391
} catch (e) {
368
- if (mounted) setState(() => error = errorText(e));
392
+ if (mounted) {
393
+ setState(() => error = errorText(e));
394
+ }
395
} finally {
370
- if (mounted) setState(() => busy = false);
396
+ if (mounted) {
397
+ setState(() => busy = false);
398
+ }
399
}
400
}
401
@@ -407,13 +435,19 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
435
setState(() { busy = true; error = null; });
436
try {
437
await widget.api.changePassword(current.text, next.text);
410
- if (!mounted) return;
438
+ if (!mounted) {
439
+ return;
440
+ }
441
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('رمز عبور تغییر کرد.')));
442
Navigator.pop(context);
443
} catch (e) {
414
- if (mounted) setState(() => error = errorText(e));
444
+ if (mounted) {
445
+ setState(() => error = errorText(e));
446
+ }
447
} finally {
416
- if (mounted) setState(() => busy = false);
448
+ if (mounted) {
449
+ setState(() => busy = false);
450
+ }
451
}
452
}
453
@@ -569,7 +603,9 @@ class _ProfileFamilyPageState extends State<ProfileFamilyPage> {
603
TextButton(onPressed: () => Navigator.pop(dialogContext, false), child: const Text('انصراف')),
604
FilledButton(
605
onPressed: () async {
572
- if (name.text.trim().isEmpty) return;
606
+ if (name.text.trim().isEmpty) {
607
+ return;
608
+ }
609
await widget.api.createFamily(name.text.trim(), role: 'parent_guardian');
610
if (dialogContext.mounted) {
611
Navigator.pop(dialogContext, true);
@@ -581,7 +617,9 @@ class _ProfileFamilyPageState extends State<ProfileFamilyPage> {
617
),
618
);
619
name.dispose();
584
- if (created == true && mounted) setState(() => data = load());
620
+ if (created == true && mounted) {
621
+ setState(() => data = load());
622
+ }
623
}
624
625
Future<void> invite(String familyId) async {
@@ -640,7 +678,9 @@ class _ProfileFamilyPageState extends State<ProfileFamilyPage> {
678
role: role,
679
themePreference: theme,
680
);
643
- if (dialogContext.mounted) Navigator.pop(dialogContext, true);
681
+ if (dialogContext.mounted) {
682
+ Navigator.pop(dialogContext, true);
683
+ }
684
},
685
child: const Text('ارسال دعوت'),
686
),
@@ -662,8 +702,12 @@ class _ProfileFamilyPageState extends State<ProfileFamilyPage> {
702
body: FutureBuilder<List<dynamic>>(
703
future: data,
704
builder: (context, snapshot) {
665
- if (snapshot.hasError) return Center(child: Text(errorText(snapshot.error!)));
666
- if (!snapshot.hasData) return const Center(child: CircularProgressIndicator());
705
+ if (snapshot.hasError) {
706
+ return Center(child: Text(errorText(snapshot.error!)));
707
+ }
708
+ if (!snapshot.hasData) {
709
+ return const Center(child: CircularProgressIndicator());
710
+ }
711
final profile = snapshot.data![0] as Map<String, dynamic>;
712
final families = snapshot.data![1] as List<Map<String, dynamic>>;
713
return ListView(
@@ -804,7 +848,9 @@ class _FamilyMembersPageState extends State<FamilyMembersPage> {
848
)
849
.toList(),
850
onChanged: (v) {
807
- if (v != null) guardianId.value = v;
851
+ if (v != null) {
852
+ guardianId.value = v;
853
+ }
854
},
855
),
856
),
@@ -823,7 +869,9 @@ class _FamilyMembersPageState extends State<FamilyMembersPage> {
869
)
870
.toList(),
871
onChanged: (v) {
826
- if (v != null) minorId.value = v;
872
+ if (v != null) {
873
+ minorId.value = v;
874
+ }
875
},
876
),
877
),