I am building an app which checks if the user is logged in or not and accordingly chooses Home or login page. If logged in, user is presented with a side menu, with first option in the menu auto selected. Now, if the first menu item is search then url should show www.abcd.com\search, but, this is not happening, and url remains as www.abcd.com
void main() {
WidgetsFlutterBinding.ensureInitialized();
setUrlStrategy(PathUrlStrategy());
runApp(
MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => Auth()),
],
child: MaterialApp(
debugShowCheckedModeBanner: false,
navigatorKey: NavigatorKeys.mainNavigationKey,
onGenerateRoute: RouteConfiguration.onGenerateRoute,
theme: ThemeData(
elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(kPrimaryColor),
),
),
scaffoldBackgroundColor: Colors.white,
textTheme: const TextTheme(
button: TextStyle(
color: Colors.white, fontWeight: FontWeight.bold))),
home: const MyApp()),
),
);
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return Consumer(builder: (_, authObj, child) {
// print('is loading ${authObj.isLoading}');
return authObj.isLoading
? const Center(child: CircularProgressIndicator())
: authObj.isLoggedIn
? const HomePage()
: const LandingPage();
});
}
}
home.dart
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
// return const Search();
return Navigator(
initialRoute: '/search',
key: NavigatorKeys.sideNavigationKey,
onGenerateRoute: RouteConfiguration.onGenerateRoute,
);
}
}
