@@ -56,15 +56,15 @@ class _AccountPageState extends State<AccountPage> {
5656 end: Alignment .bottomRight,
5757 colors: [
5858 colors.primary,
59- colors.primary.withOpacity ( 0.8 ),
59+ colors.primary.withValues (alpha : 0.8 ),
6060 ],
6161 ),
6262 ),
6363 child: Column (
6464 children: [
6565 CircleAvatar (
6666 radius: 50 ,
67- backgroundColor: colors.onPrimary.withOpacity ( 0.2 ),
67+ backgroundColor: colors.onPrimary.withValues (alpha : 0.2 ),
6868 child: Text (
6969 "${_currentUser .firstName [0 ].toUpperCase ()}${_currentUser .lastName [0 ].toUpperCase ()}" ,
7070 style: textTheme.headlineMedium? .copyWith (
@@ -85,16 +85,16 @@ class _AccountPageState extends State<AccountPage> {
8585 Text (
8686 _currentUser.email,
8787 style: textTheme.bodyMedium? .copyWith (
88- color: colors.onPrimary.withOpacity ( 0.8 ),
88+ color: colors.onPrimary.withValues (alpha : 0.8 ),
8989 ),
9090 ),
9191 const SizedBox (height: 12 ),
9292 Container (
9393 padding: const EdgeInsets .symmetric (horizontal: 12 , vertical: 4 ),
9494 decoration: BoxDecoration (
95- color: colors.onPrimary.withOpacity ( 0.15 ),
95+ color: colors.onPrimary.withValues (alpha : 0.15 ),
9696 borderRadius: BorderRadius .circular (20 ),
97- border: Border .all (color: colors.onPrimary.withOpacity ( 0.3 )),
97+ border: Border .all (color: colors.onPrimary.withValues (alpha : 0.3 )),
9898 ),
9999 child: Text (
100100 _currentUser.accountType == 0 ? "Compte Client" : "Compte Restaurateur" ,
@@ -192,7 +192,7 @@ class _AccountPageState extends State<AccountPage> {
192192 elevation: 0 ,
193193 shape: RoundedRectangleBorder (
194194 borderRadius: BorderRadius .circular (16 ),
195- side: BorderSide (color: Theme .of (context).colorScheme.outlineVariant.withOpacity ( 0.5 )),
195+ side: BorderSide (color: Theme .of (context).colorScheme.outlineVariant.withValues (alpha : 0.5 )),
196196 ),
197197 color: Theme .of (context).colorScheme.surfaceContainerLow,
198198 child: Column (children: children),
@@ -228,7 +228,7 @@ class _AccountPageState extends State<AccountPage> {
228228 height: 1 ,
229229 indent: 56 ,
230230 endIndent: 16 ,
231- color: colors.outlineVariant.withOpacity ( 0.3 ),
231+ color: colors.outlineVariant.withValues (alpha : 0.3 ),
232232 ),
233233 ],
234234 );
@@ -253,9 +253,11 @@ class _AccountPageState extends State<AccountPage> {
253253 onNext: (updatedUser) async {
254254 try {
255255 await userRepo.updateProfile (updatedUser);
256+ if (! context.mounted) return ;
256257 Navigator .pop (context);
257258 _refreshProfile ();
258259 } catch (e) {
260+ if (! context.mounted) return ;
259261 ScaffoldMessenger .of (context).showSnackBar (
260262 SnackBar (content: Text ('Erreur: $e ' )),
261263 );
@@ -277,13 +279,15 @@ class _AccountPageState extends State<AccountPage> {
277279 onConfirm: (oldPwd, newPwd) async {
278280 try {
279281 final success = await userRepo.changePassword (oldPwd, newPwd);
282+ if (! context.mounted) return ;
280283 if (success) {
281284 Navigator .pop (context);
282285 ScaffoldMessenger .of (context).showSnackBar (
283286 const SnackBar (content: Text ('Mot de passe mis à jour !' )),
284287 );
285288 }
286289 } catch (e) {
290+ if (! context.mounted) return ;
287291 ScaffoldMessenger .of (context).showSnackBar (
288292 SnackBar (content: Text ('Erreur: $e ' )),
289293 );
@@ -324,8 +328,8 @@ class _AccountPageState extends State<AccountPage> {
324328 void _showDeleteAccountDialog (BuildContext context) {
325329 showDialog (
326330 context: context,
327- builder: (BuildContext context ) {
328- final colors = Theme .of (context ).colorScheme;
331+ builder: (BuildContext dialogContext ) {
332+ final colors = Theme .of (dialogContext ).colorScheme;
329333 return AlertDialog (
330334 title: const Text ("Supprimer le compte" ),
331335 content: const Text (
@@ -334,20 +338,22 @@ class _AccountPageState extends State<AccountPage> {
334338 shape: RoundedRectangleBorder (borderRadius: BorderRadius .circular (16 )),
335339 actions: [
336340 TextButton (
337- onPressed: () => Navigator .pop (context ),
341+ onPressed: () => Navigator .pop (dialogContext ),
338342 child: const Text ("Annuler" ),
339343 ),
340344 FilledButton (
341345 onPressed: () async {
342346 try {
343347 final success = await userRepo.deleteAccount ();
348+ if (! dialogContext.mounted) return ;
344349 if (success) {
345- Navigator .pop (context );
350+ Navigator .pop (dialogContext );
346351 widget.onLogout ();
347352 }
348353 } catch (e) {
349- Navigator .pop (context);
350- ScaffoldMessenger .of (context).showSnackBar (
354+ if (! dialogContext.mounted) return ;
355+ Navigator .pop (dialogContext);
356+ ScaffoldMessenger .of (dialogContext).showSnackBar (
351357 SnackBar (content: Text ('Erreur: $e ' )),
352358 );
353359 }
0 commit comments