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 {
|
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
|
@override
|
||||||
State<StatefulWidget> createState() => _FriendsListAppBarState();
|
State<StatefulWidget> createState() => _FriendsListAppBarState();
|
||||||
|
|
@ -270,12 +273,11 @@ class _FriendsListAppBarState extends State<FriendsListAppBar> {
|
||||||
name: "Find Users",
|
name: "Find Users",
|
||||||
icon: Icons.person_add,
|
icon: Icons.person_add,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final mClient = Provider.of<MessagingClient>(context, listen: false);
|
|
||||||
await Navigator.of(context).push(
|
await Navigator.of(context).push(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) =>
|
||||||
ChangeNotifierProvider<MessagingClient>.value(
|
ChangeNotifierProvider<MessagingClient>.value(
|
||||||
value: mClient,
|
value: widget.mClient,
|
||||||
child: const UserSearch(),
|
child: const UserSearch(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,6 @@ class _UserSearchState extends State<UserSearch> {
|
||||||
iconOverride: err.icon,
|
iconOverride: err.icon,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
FlutterError.reportError(
|
|
||||||
FlutterErrorDetails(exception: snapshot.error!, stack: snapshot.stackTrace));
|
|
||||||
return DefaultErrorWidget(title: "${snapshot.error}",);
|
return DefaultErrorWidget(title: "${snapshot.error}",);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class Home extends StatefulWidget {
|
||||||
class _HomeState extends State<Home> with AutomaticKeepAliveClientMixin {
|
class _HomeState extends State<Home> with AutomaticKeepAliveClientMixin {
|
||||||
final PageController _pageController = PageController(initialPage: 1);
|
final PageController _pageController = PageController(initialPage: 1);
|
||||||
ClientHolder? _clientHolder;
|
ClientHolder? _clientHolder;
|
||||||
MessagingClient? _mClient;
|
late MessagingClient _mClient;
|
||||||
int _currentPageIndex = 1;
|
int _currentPageIndex = 1;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -54,7 +54,7 @@ class _HomeState extends State<Home> with AutomaticKeepAliveClientMixin {
|
||||||
NavigationDestination(icon: Icon(Icons.location_city), label: "Sessions")
|
NavigationDestination(icon: Icon(Icons.location_city), label: "Sessions")
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
appBar: const FriendsListAppBar(),
|
appBar: FriendsListAppBar(mClient: _mClient,),
|
||||||
body: PageView(
|
body: PageView(
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
controller: _pageController,
|
controller: _pageController,
|
||||||
|
|
@ -72,6 +72,5 @@ class _HomeState extends State<Home> with AutomaticKeepAliveClientMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// TODO: implement wantKeepAlive
|
|
||||||
bool get wantKeepAlive => true;
|
bool get wantKeepAlive => true;
|
||||||
}
|
}
|
||||||
Reference in a new issue