Fix broken user search caused by missing mClient
This commit is contained in:
parent
aabb23f326
commit
a823604822
3 changed files with 7 additions and 8 deletions
|
@ -106,7 +106,10 @@ class _FriendsListState extends State<FriendsList> 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<StatefulWidget> createState() => _FriendsListAppBarState();
|
||||
|
@ -270,12 +273,11 @@ class _FriendsListAppBarState extends State<FriendsListAppBar> {
|
|||
name: "Find Users",
|
||||
icon: Icons.person_add,
|
||||
onTap: () async {
|
||||
final mClient = Provider.of<MessagingClient>(context, listen: false);
|
||||
await Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
ChangeNotifierProvider<MessagingClient>.value(
|
||||
value: mClient,
|
||||
value: widget.mClient,
|
||||
child: const UserSearch(),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -85,8 +85,6 @@ class _UserSearchState extends State<UserSearch> {
|
|||
iconOverride: err.icon,
|
||||
);
|
||||
} else {
|
||||
FlutterError.reportError(
|
||||
FlutterErrorDetails(exception: snapshot.error!, stack: snapshot.stackTrace));
|
||||
return DefaultErrorWidget(title: "${snapshot.error}",);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -16,7 +16,7 @@ class Home extends StatefulWidget {
|
|||
class _HomeState extends State<Home> 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<Home> 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<Home> with AutomaticKeepAliveClientMixin {
|
|||
}
|
||||
|
||||
@override
|
||||
// TODO: implement wantKeepAlive
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
Loading…
Reference in a new issue