Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve GoRouter.routeInformationProvider missing error?

Tags:

flutter

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.

like image 718
Mg Bhadurudeen Avatar asked May 06 '26 08:05

Mg Bhadurudeen


1 Answers

Just add routeInformationProvider to MaterialApp.router.

Example:

  final _router = GoRouter(
         ...
  );

  @override
  Widget build(BuildContext context) {
      return MaterialApp.router(
          routeInformationProvider: _router.routeInformationProvider,
          ...
       );
   }
like image 88
baihu92 Avatar answered May 08 '26 01:05

baihu92



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!