fix(doc): update the use of GoRouter in the guides
This commit is contained in:
@@ -489,47 +489,51 @@ class _MyAppState extends State<MyApp> {
|
||||
|
||||
late final _router = GoRouter(
|
||||
initialLocation: '/',
|
||||
navigatorBuilder: (context, state, child) {
|
||||
if (state.location.startsWith('/chat')) {
|
||||
wasPreviousRouteChat = true;
|
||||
return StreamChat(
|
||||
client: _client,
|
||||
child: ChatSetup(client: _client, child: child),
|
||||
);
|
||||
} else {
|
||||
if (wasPreviousRouteChat) {
|
||||
wasPreviousRouteChat = false;
|
||||
return StreamChat(
|
||||
client: _client,
|
||||
child: child,
|
||||
);
|
||||
} else {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
},
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/',
|
||||
builder: (context, state) => const HomeScreen(),
|
||||
ShellRoute(
|
||||
builder: (context, state, child) {
|
||||
if (state.uri.host.startsWith('/chat')) {
|
||||
wasPreviousRouteChat = true;
|
||||
return StreamChat(
|
||||
client: _client,
|
||||
child: ChatSetup(client: _client, child: child),
|
||||
);
|
||||
} else {
|
||||
if (wasPreviousRouteChat) {
|
||||
wasPreviousRouteChat = false;
|
||||
return StreamChat(
|
||||
client: _client,
|
||||
child: child,
|
||||
);
|
||||
} else {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
},
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'settings',
|
||||
builder: (context, state) => const SettingsPage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chat',
|
||||
builder: (context, state) => const ChannelListPage(),
|
||||
path: '/',
|
||||
builder: (context, state) => const HomeScreen(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'channel',
|
||||
builder: (context, state) {
|
||||
final channel = state.extra as Channel;
|
||||
return StreamChannel(
|
||||
channel: channel,
|
||||
child: const ChannelPage(),
|
||||
);
|
||||
},
|
||||
path: 'settings',
|
||||
builder: (context, state) => const SettingsPage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: 'chat',
|
||||
builder: (context, state) => const ChannelListPage(),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'channel',
|
||||
builder: (context, state) {
|
||||
final channel = state.extra as Channel;
|
||||
return StreamChannel(
|
||||
channel: channel,
|
||||
child: const ChannelPage(),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user