diff --git a/lib/widgets/friends/friends_list.dart b/lib/widgets/friends/friends_list.dart index a83429f..2c211bc 100644 --- a/lib/widgets/friends/friends_list.dart +++ b/lib/widgets/friends/friends_list.dart @@ -106,7 +106,10 @@ class _FriendsListState extends State with AutomaticKeepAliveClient } class FriendsListAppBar extends StatefulWidget implements PreferredSizeWidget { - const FriendsListAppBar({super.key}); + const FriendsListAppBar({required this.mClient, super.key}); + + // Passing this instance around like this is kinda dirty, I want to try to find a cleaner way to do this using Provider + final MessagingClient mClient; @override State createState() => _FriendsListAppBarState(); @@ -270,12 +273,11 @@ class _FriendsListAppBarState extends State { name: "Find Users", icon: Icons.person_add, onTap: () async { - final mClient = Provider.of(context, listen: false); await Navigator.of(context).push( MaterialPageRoute( builder: (context) => ChangeNotifierProvider.value( - value: mClient, + value: widget.mClient, child: const UserSearch(), ), ), diff --git a/lib/widgets/friends/user_search.dart b/lib/widgets/friends/user_search.dart index fd90f2b..7180ac5 100644 --- a/lib/widgets/friends/user_search.dart +++ b/lib/widgets/friends/user_search.dart @@ -85,8 +85,6 @@ class _UserSearchState extends State { iconOverride: err.icon, ); } else { - FlutterError.reportError( - FlutterErrorDetails(exception: snapshot.error!, stack: snapshot.stackTrace)); return DefaultErrorWidget(title: "${snapshot.error}",); } } else { diff --git a/lib/widgets/home.dart b/lib/widgets/home.dart index a577814..bf6dba1 100644 --- a/lib/widgets/home.dart +++ b/lib/widgets/home.dart @@ -16,7 +16,7 @@ class Home extends StatefulWidget { class _HomeState extends State with AutomaticKeepAliveClientMixin { final PageController _pageController = PageController(initialPage: 1); ClientHolder? _clientHolder; - MessagingClient? _mClient; + late MessagingClient _mClient; int _currentPageIndex = 1; @override @@ -54,7 +54,7 @@ class _HomeState extends State with AutomaticKeepAliveClientMixin { NavigationDestination(icon: Icon(Icons.location_city), label: "Sessions") ], ), - appBar: const FriendsListAppBar(), + appBar: FriendsListAppBar(mClient: _mClient,), body: PageView( physics: const NeverScrollableScrollPhysics(), controller: _pageController, @@ -72,6 +72,5 @@ class _HomeState extends State with AutomaticKeepAliveClientMixin { } @override - // TODO: implement wantKeepAlive bool get wantKeepAlive => true; } \ No newline at end of file