flutter-go-router-example icon indicating copy to clipboard operation
flutter-go-router-example copied to clipboard

NavigatorObserver can't be used as a mixin because it isn't a mixin class nor a mixin

Open agelospanagiotakis opened this issue 2 years ago • 2 comments

I get this error Error: The class 'NavigatorObserver' can't be used as a mixin because it isn't a mixin class nor a mixin. go_router.dart:17 class GoRouter extends ChangeNotifier with NavigatorObserver {

agelospanagiotakis avatar Aug 03 '23 10:08 agelospanagiotakis

Hi @agelospanagiotakis , you only need to update the package go_router because in the current example it has a old version go_router and otherwise you need to change main.dart because it has unnecessary parameters, so please check it out this https://stackoverflow.com/questions/76307222/error-if-the-routerconfig-is-provided-all-the-other-router-delegates-must-not Mayber you need to update all dependencies in may case I have updated and it works for me

CristhianLara1996 avatar Feb 23 '24 13:02 CristhianLara1996

try this: return MultiProvider( providers: [ ChangeNotifierProvider<AppService>(create: (_) => appService), Provider<AppRouter>(create: (_) => AppRouter(appService)), Provider<AuthService>(create: (_) => authService), ], child: Builder( builder: (context) { final GoRouter goRouter = Provider.of<AppRouter>(context, listen: false).router; return MaterialApp.router( title: "Router App", routerConfig: goRouter, // routerDelegate: goRouter.routerDelegate, // routeInformationParser: goRouter.routeInformationParser, // routeInformationProvider: goRouter.routeInformationProvider, ); }, ), );

CristhianLara1996 avatar Feb 23 '24 13:02 CristhianLara1996