# Unhandled Exception: AutoRouter operation requested with a context that does not include an AutoRouter

**URL:** <https://forums.kodeco.com/t/unhandled-exception-autorouter-operation-requested-with-a-context-that-does-not-include-an-autorouter/173587>\
**Category:** Flutter\
**Created:** [June 21, 2022, 10:35am UTC](https://forums.kodeco.com/t/unhandled-exception-autorouter-operation-requested-with-a-context-that-does-not-include-an-autorouter/173587 "2022-06-21T10:35:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mysteriondex](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mysteriondex/32/102075_2.png) [@mysteriondex](https://forums.kodeco.com/u/mysteriondex)\
**Post date:** [June 21, 2022, 10:35am UTC](https://forums.kodeco.com/t/unhandled-exception-autorouter-operation-requested-with-a-context-that-does-not-include-an-autorouter/173587/1 "2022-06-21T10:35:48Z")

</div>

Hello hello

I’m getting this error: Unhandled Exception: AutoRouter operation requested with a context that does not include an AutoRouter. The context used to retrieve the Router must be that of a widget that is a descendant of an AutoRouter widget.

Any idea how I can fix it please ?

I already asked on Stackoverflow, but I got no answer ☹

```auto
class App extends StatefulWidget {
  late AppRouter _appRouter;
  late KeycloakAuth _auth;

  App(KeycloakAuth auth, {Key? key}) : super(key: key) {
    _auth = auth;
    _appRouter = AppRouter(authGuard: AuthGuard(_auth));
  }

  @override
  State<App> createState() => _AppState();
}

class _AppState extends State<App> with TickerProviderStateMixin {
  late final AnimationController _controller;

  @override
  void initState() {
    super.initState();

    _controller = AnimationController(vsync: this);
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(
          create: (_) => widget._auth,
        ),
        ChangeNotifierProvider(
          create: (_) => PaymentIntentProvider(),
        ),
        BlocProvider<ItemCategoriesBloc>(
            create: (context) =>
                ItemCategoriesBloc(APIProvider.backendAPI)..add(LoadItemCategoriesEvent())),
        BlocProvider<NgosBloc>(
            create: ((context) => NgosBloc(APIProvider.backendAPI)..add(LoadNgosEvent()))),
        BlocProvider<ProfileBloc>(create: (context) => ProfileBloc(APIProvider.backendAPI)),
        BlocProvider<PrivateProfileBloc>(
            create: (context) => PrivateProfileBloc(APIProvider.backendAPI, widget._auth.userId)
              ..add(LoadPrivateProfile())),
        BlocProvider<ItemBloc>(create: (context) => ItemBloc(APIProvider.backendAPI)),
        BlocProvider<ItemsListBloc>(
            create: (context) => ItemsListBloc(APIProvider.backendAPI)..add(LoadItemsList())),
        BlocProvider<ConversationBloc>(
            create: (context) => ConversationBloc(APIProvider.backendAPI)),
        BlocProvider<ConversationsListBloc>(
            create: (context) =>
                ConversationsListBloc(APIProvider.backendAPI)..add(LoadConversationsList())),
        BlocProvider<SearchBloc>(create: (context) => SearchBloc(APIProvider.backendAPI)),
      ],
      child: MaterialApp(
        debugShowCheckedModeBanner: false,
        title: 'TrödelSpende',
        home: AnimatedSplashScreen(
          animationDuration: const Duration(seconds: 7),
          splashIconSize: double.maxFinite,
          splash: Lottie.asset(
            'assets/Logo-3-[remix]-[remix].json',
          ),
          nextScreen: MaterialApp.router(
            debugShowCheckedModeBanner: false,
            theme: MyTheme.create(),
            localizationsDelegates: context.localizationDelegates,
            supportedLocales: context.supportedLocales,
            locale: context.locale,
            routerDelegate: AutoRouterDelegate(widget._appRouter,
                navigatorObservers: () => [AutoRouteObserver()]),
            routeInformationProvider: widget._appRouter.routeInfoProvider(),
            routeInformationParser: widget._appRouter.defaultRouteParser(),
          ),
        ),
      ),
    );
  }
}

```

Thank you in advance for your help 😃

---

<div class="post-metadata">

**Author:** ![lauragales](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/lauragales/32/110821_2.png) [@lauragales](https://forums.kodeco.com/u/lauragales)\
**Post date:** [June 21, 2022, 3:35pm UTC](https://forums.kodeco.com/t/unhandled-exception-autorouter-operation-requested-with-a-context-that-does-not-include-an-autorouter/173587/2 "2022-06-21T15:35:56Z")

</div>

In your providers list, it seems to have a rogue opening parentheses `create: ((context) => NgosBloc`

And a closing parentheses can be removed at the end of the line `..add(LoadNgosEvent())))`

So  
`create: (context) => NgosBloc`  
And  
`..add(LoadNgosEvent()))`

---

<div class="post-metadata">

**Author:** ![mysteriondex](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/mysteriondex/32/102075_2.png) [@mysteriondex](https://forums.kodeco.com/u/mysteriondex)\
**Post date:** [June 22, 2022, 9:00am UTC](https://forums.kodeco.com/t/unhandled-exception-autorouter-operation-requested-with-a-context-that-does-not-include-an-autorouter/173587/3 "2022-06-22T09:00:58Z")

</div>

Thank you for your answer but I don’t think that’s what is causing the error ☹
