fix physical button navigation on android
This commit is contained in:
@@ -17,14 +17,22 @@ class HomePage extends StatelessWidget {
|
|||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final StreamChatClient chatClient;
|
final StreamChatClient chatClient;
|
||||||
|
final GlobalKey<NavigatorState> _navigatorKey = GlobalKey();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return StreamChat(
|
return StreamChat(
|
||||||
client: chatClient,
|
client: chatClient,
|
||||||
child: Navigator(
|
child: WillPopScope(
|
||||||
onGenerateRoute: AppRoutes.generateRoute,
|
onWillPop: () async {
|
||||||
initialRoute: Routes.CHANNEL_LIST_PAGE,
|
final canPop = await _navigatorKey.currentState?.maybePop() ?? false;
|
||||||
|
return !canPop;
|
||||||
|
},
|
||||||
|
child: Navigator(
|
||||||
|
key: _navigatorKey,
|
||||||
|
onGenerateRoute: AppRoutes.generateRoute,
|
||||||
|
initialRoute: Routes.CHANNEL_LIST_PAGE,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user