isInitialRoute error
hemguna opened this issue · 1 comments
hemguna commented
lwluck commented
From https://flutter.dev/docs/release/breaking-changes/route-navigator-refactoring
Finally, we removed the isInitialRoute property from RouteSetting as part of refactoring, and provided the onGenerateInitialRoutes API for full control of initial routes generation.
There is a migration guide on that page as well. I will have a PR up shortly which I believe fixes it and cleans up some naming issues I noticed, but the below seems to work.
main.dart
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'E-Commerce ',
theme: AppTheme.lightTheme.copyWith(
textTheme: GoogleFonts.muliTextTheme(
Theme.of(context).textTheme,
),
),
debugShowCheckedModeBanner: false,
routes: Routes.getRoute(),
onGenerateRoute: (RouteSettings settings) {
if (settings.name.contains('detail')) {
return CustomRoute<bool>(
builder: (BuildContext context) => ProductDetailPage());
} else {
return CustomRoute<bool>(
builder: (BuildContext context) => MainPage());
}
},
initialRoute: "MainPage",
);
}
}
customRoute.dart
class CustomRoute<T> extends MaterialPageRoute<T> {
CustomRoute({WidgetBuilder builder, RouteSettings settings})
: super(builder: builder, settings: settings);
@override
Widget buildTransitions(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
if (settings.name == "MainPage") {
return child;
}
return FadeTransition(
opacity: animation,
child: child,
);
}
}