Home > OS >  How to solve GoRouter.routeInformationProvider missing error?
How to solve GoRouter.routeInformationProvider missing error?

Time:06-26

The flutter team has given the following flutter project created by them, to learn from. https://github.com/flutter/codelabs/tree/main/boring_to_beautiful through their codelab.

I cloned the repo and tried to start the app. But it throws the following error.

════════ Exception caught by widgets library The following assertion was thrown building IconTheme(color: Color(0xdd000000)): This GoRouteInformationParser needs to be used with GoRouteInformationProvider, did you forget to pass in GoRouter.routeInformationProvider to the Router constructor? 'package:go_router/src/go_route_information_parser.dart': package:go_router/src/go_route_information_parser.dart:1 Failed assertion: line 148 pos 13: 'routeInformation is DebugGoRouteInformation'

From this error msg, I could understand that 'routeInformationProvider' seems to be missing. But is that possible in a working demo project given by the flutter team to learn from? Should I pass the routeInformationProvider? if so any docs, please.

CodePudding user response:

Just add routeInformationProvider to MaterialApp.router.

Example:

  final _router = GoRouter(
         ...
  );

  @override
  Widget build(BuildContext context) {
      return MaterialApp.router(
          routeInformationProvider: _router.routeInformationProvider,
          ...
       );
   }

CodePudding user response:

Just go back to version 3.1.1 of GoRouter. It seems latest version has an issue

  • Related