Open paakjis opened 1 year ago
I got it. After hours of seraching. The App Widget needs to be StatefulWidget for the hot-reload to work properly.
class App extends StatefulWidget {
const App({super.key});
@override
State<App> createState() => _AppState();
}
class _AppState extends State<App> {
final _appRouter = AppRouter();
@override
Widget build(BuildContext context) {
return MaterialApp.router(
theme: ThemeData(
appBarTheme: const AppBarTheme(color: Color.blue),
colorScheme: ColorScheme.fromSwatch(accentColor: Color.blue),
// fontFamily: 'Roboto',
),
routerDelegate: AutoRouterDelegate(
_appRouter,
navigatorObservers: () => [AppRouteObserver()],
),
routeInformationProvider: _appRouter.routeInfoProvider(),
routeInformationParser: _appRouter.defaultRouteParser(),
localizationsDelegates: const [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
],
useInheritedMediaQuery: true,
supportedLocales: AppLocalizations.supportedLocales,
builder: (BuildContext context, Widget? child) {
final data = MediaQuery.of(context);
return MediaQuery(
data: data.copyWith(
textScaleFactor: 1,
),
child: child!,
);
},
);
}
}
Hi. Im new to AutoRoute, I cant figure out how to make more pages with this boilerplate. So I made something liek this.
But the problem here is that after flutters "hot reload" it triggers the AppStartPage, and opens the HomePage again.
How do I make it so it doesn't open HomePage everytime it reloads?