From 90adcc6bb1620acb744616f5f9bf753d2ae3d688 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 28 Mar 2023 17:21:35 +0200 Subject: [PATCH] Fixed context bugs caused by moving to GoRouter NOTE: Some bugs have not been fixed, and the member screen needs fixing, but before that can happen, localstore has to be replaced, because it causes loops on android and linux. It also seems like it might lead to memory leaks --- lib/screens/room/edit.dart | 12 +----------- lib/screens/room/members.dart | 8 ++++---- lib/screens/room/pages/about.dart | 6 +++--- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/lib/screens/room/edit.dart b/lib/screens/room/edit.dart index b1c2aec..d96e96e 100644 --- a/lib/screens/room/edit.dart +++ b/lib/screens/room/edit.dart @@ -132,14 +132,6 @@ class _EditRoomPageState extends State { : Scaffold( appBar: AppBar( title: const Text('Edit Room'), - leading: IconButton( - onPressed: () { - // go back - Navigator.of(context).pop(); - }, - icon: const Icon(Icons.arrow_back), - tooltip: "Go back", - ), ), body: SingleChildScrollView( child: Center( @@ -191,9 +183,7 @@ class _EditRoomPageState extends State { _ctrIcon = icon; }); - Navigator.of( - context) - .pop(); + context.pop(); })); }).toList())), )); diff --git a/lib/screens/room/members.dart b/lib/screens/room/members.dart index 6d920f8..f897484 100644 --- a/lib/screens/room/members.dart +++ b/lib/screens/room/members.dart @@ -266,7 +266,7 @@ class _ManageRoomMembersPageState extends State { showDialog( context: context, builder: - (context) => + (ctx) => AlertDialog( icon: const Icon( Icons @@ -283,7 +283,7 @@ class _ManageRoomMembersPageState extends State { // NOTE: cancel only closes the dialog // whilst OK closes both - Navigator.of(context) + Navigator.of(ctx) .pop(); }, child: const Text( @@ -294,9 +294,9 @@ class _ManageRoomMembersPageState extends State { () async { // send request final scaffMgr = - ScaffoldMessenger.of(context); + ScaffoldMessenger.of(ctx); final nav = - Navigator.of(context); + Navigator.of(ctx); final user = context.read(); diff --git a/lib/screens/room/pages/about.dart b/lib/screens/room/pages/about.dart index 1559575..60a3168 100644 --- a/lib/screens/room/pages/about.dart +++ b/lib/screens/room/pages/about.dart @@ -97,7 +97,7 @@ class _AboutRoomPageState extends State { actions: [ TextButton( onPressed: () { - Navigator.of(context).pop(); + context.pop(); }, child: const Text('Cancel'), ), @@ -272,8 +272,8 @@ class _AboutRoomPageState extends State { final scaffMgr = ScaffoldMessenger.of(ctx); final nav = Navigator.of(ctx); - final router = GoRouter.of(ctx); - final user = ctx.read(); + final router = GoRouter.of(context); + final user = context.read(); doNetworkRequest(scaffMgr, req: () => postWithCreadentials(