---
title: "Comment by Renato Dehnhardt on \"Flutter Authentication Flow with Go Router and Provider\" | Hashnode"
description: "Hey man, nice tutorial, I really like the way that you create the authentication process! And I'm trying to do something like this. I'm got this error when try"
url: "https://hashnode.com/posts/flutter-authentication-flow-with-go-router-and-provider/61c37acec0206b3f41f549c5/comment/65e2ec3f202854fd6070fe16"
---

[Discussion](https://hashnode.com/posts/flutter-authentication-flow-with-go-router-and-provider/61c37acec0206b3f41f549c5)

Comment [Flutter Authentication Flow with Go Router and Provider](https://hashnode.com/posts/flutter-authentication-flow-with-go-router-and-provider/61c37acec0206b3f41f549c5)

[Renato Dehnhardt](https://hashnode.com/@rawnato)

[Mar 2, 2024](https://hashnode.com/posts/flutter-authentication-flow-with-go-router-and-provider/61c37acec0206b3f41f549c5/comment/65e2ec3f202854fd6070fe16)

Hey man, nice tutorial, I really like the way that you create the authentication process! And I'm trying to do something like this. I'm got this error when try to execute the project!

```
unknown route name: /start
'package:go_router/src/configuration.dart':
Failed assertion: line 266 pos 12: '_nameToPath.containsKey(name)'
```

and everything it's is like the tutorial! Do you known if the problem are caused by some different version or something like this?

[Renato Dehnhardt](https://hashnode.com/@rawnato)

[Mar 2, 2024](https://hashnode.com/posts/flutter-authentication-flow-with-go-router-and-provider/61c37acec0206b3f41f549c5/comment/65e2ec3f202854fd6070fe16#reply-65e2f2669e0e76c546f652cb)

I found the problem, I think this is something related to new version of GoRouter or something like this.

Before

```
final loginLocation = state.namedLocation(APP_PAGE.login.toPath);
final homeLocation = state.namedLocation(APP_PAGE.home.toPath);
final splashLocation = state.namedLocation(APP_PAGE.splash.toPath);
final onboardLocation = state.namedLocation(APP_PAGE.onBoarding.toPath);
```

After

```
final onBoardLocation = state.namedLocation(APP_PAGE.onBoarding.toName);
final splashLocation = state.namedLocation(APP_PAGE.splash.toName);
final loginLocation = state.namedLocation(APP_PAGE.login.toName);
final homeLocation = state.namedLocation(APP_PAGE.home.toName);
```

But now there's this exception.

```
======== Exception caught by foundation library ====================================================
The following assertion was thrown while dispatching notifications for GoRouterDelegate:
setState() or markNeedsBuild() called during build.

This Router<Object> widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget can be marked as needing to be built during the build phase only if one of its ancestors is currently building. This exception is allowed because the framework builds parent widgets before children, which means a dirty descendant will always be built. Otherwise, the framework might not visit this widget during this build phase.
The widget on which setState() or markNeedsBuild() was called was: Router<Object>
  dependencies: [UnmanagedRestorationScope]
  state: _RouterState<Object>#2674b
The widget which was currently being built when the offending call was made was: Builder
When the exception was thrown, this was the stack: 
#0      Element.markNeedsBuild.<anonymous closure> (package:flutter/src/widgets/framework.dart:5042:9)
#1      Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:5054:6)
#2      State.setState (package:flutter/src/widgets/framework.dart:1223:15)
#3      _RouterState._handleRouterDelegateNotification (package:flutter/src/widgets/router.dart:796:5)
#4      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:433:24)
#5      GoRouterDelegate._setCurrentConfiguration (package:go_router/src/delegate.dart:269:5)
#6      GoRouterDelegate.setNewRoutePath.<anonymous closure> (package:go_router/src/delegate.dart:231:18)
#7      SynchronousFuture.then (package:flutter/src/foundation/synchronous_future.dart:43:39)
#8      GoRouterDelegate.setNewRoutePath (package:go_router/src/delegate.dart:227:14)
#9      _RouterState._processParsedRouteInformation.<anonymous closure> (package:flutter/src/widgets/router.dart:758:34)
#10     SynchronousFuture.then (package:flutter/src/foundation/synchronous_future.dart:43:39)
#11     _RouterState._processRouteInformation (package:flutter/src/widgets/router.dart:750:8)
#12     _RouterState._handleRouteInformationProviderNotification (package:flutter/src/widgets/router.dart:767:5)
#13     ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:433:24)
#14     GoRouteInformationProvider.notifyListeners (package:go_router/src/information_provider.dart:134:11)
#15     ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:433:24)
#16     AppService.onAppStart (package:customers/services/app_service.dart:48:5)
#17     _SplashPageState.onStartUp (package:customers/pages/splash/page.dart:27:22)
#18     _SplashPageState.initState (package:customers/pages/splash/page.dart:21:5)
#19     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:5611:55)
#20     ComponentElement.mount (package:flutter/src/widgets/framework.dart:5456:5)
...     Normal element mounting (226 frames)
#246    Element.inflateWidget (package:flutter/src/widgets/framework.dart:4335:16)
#247    MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6893:36)
#248    MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6905:32)
...     Normal element mounting (487 frames)
#735    _InheritedProviderScopeElement.mount (package:provider/src/inherited_provider.dart:411:11)
...     Normal element mounting (7 frames)
#742    SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (7 frames)
#749    _NestedHookElement.mount (package:nested/nested.dart:187:11)
...     Normal element mounting (7 frames)
#756    _InheritedProviderScopeElement.mount (package:provider/src/inherited_provider.dart:411:11)
...     Normal element mounting (7 frames)
#763    SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (7 frames)
#770    _NestedHookElement.mount (package:nested/nested.dart:187:11)
...     Normal element mounting (7 frames)
#777    _InheritedProviderScopeElement.mount (package:provider/src/inherited_provider.dart:411:11)
...     Normal element mounting (7 frames)
#784    SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (7 frames)
#791    _NestedHookElement.mount (package:nested/nested.dart:187:11)
...     Normal element mounting (7 frames)
#798    SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (35 frames)
#833    Element.inflateWidget (package:flutter/src/widgets/framework.dart:4335:16)
#834    Element.updateChild (package:flutter/src/widgets/framework.dart:3846:18)
#835    _RawViewElement._updateChild (package:flutter/src/widgets/view.dart:291:16)
#836    _RawViewElement.mount (package:flutter/src/widgets/view.dart:314:5)
...     Normal element mounting (7 frames)
#843    Element.inflateWidget (package:flutter/src/widgets/framework.dart:4335:16)
#844    Element.updateChild (package:flutter/src/widgets/framework.dart:3846:18)
#845    RootElement._rebuild (package:flutter/src/widgets/binding.dart:1354:16)
#846    RootElement.mount (package:flutter/src/widgets/binding.dart:1323:5)
#847    RootWidget.attach.<anonymous closure> (package:flutter/src/widgets/binding.dart:1276:18)
#848    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2844:19)
#849    RootWidget.attach (package:flutter/src/widgets/binding.dart:1275:13)
#850    WidgetsBinding.attachToBuildOwner (package:flutter/src/widgets/binding.dart:1088:27)
#851    WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:1070:5)
#852    WidgetsBinding.scheduleAttachRootWidget.<anonymous closure> (package:flutter/src/widgets/binding.dart:1056:7)
#856    _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
(elided 3 frames from class _Timer and dart:async-patch)
The GoRouterDelegate sending notification was: Instance of 'GoRouterDelegate'
====================================================================================================

======== Exception caught by foundation library ====================================================
The following assertion was thrown while dispatching notifications for AppService:
setState() or markNeedsBuild() called during build.

This _InheritedProviderScope<AppService?> widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget can be marked as needing to be built during the build phase only if one of its ancestors is currently building. This exception is allowed because the framework builds parent widgets before children, which means a dirty descendant will always be built. Otherwise, the framework might not visit this widget during this build phase.
The widget on which setState() or markNeedsBuild() was called was: _InheritedProviderScope<AppService?>
  value: Instance of 'AppService'
  listening to value
The widget which was currently being built when the offending call was made was: Builder
When the exception was thrown, this was the stack: 
#0      Element.markNeedsBuild.<anonymous closure> (package:flutter/src/widgets/framework.dart:5042:9)
#1      Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:5054:6)
#2      _InheritedProviderScopeElement.markNeedsNotifyDependents (package:provider/src/inherited_provider.dart:577:5)
#3      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:433:24)
#4      AppService.onAppStart (package:customers/services/app_service.dart:48:5)
#5      _SplashPageState.onStartUp (package:customers/pages/splash/page.dart:27:22)
#6      _SplashPageState.initState (package:customers/pages/splash/page.dart:21:5)
#7      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:5611:55)
#8      ComponentElement.mount (package:flutter/src/widgets/framework.dart:5456:5)
...     Normal element mounting (226 frames)
#234    Element.inflateWidget (package:flutter/src/widgets/framework.dart:4335:16)
#235    MultiChildRenderObjectElement.inflateWidget (package:flutter/src/widgets/framework.dart:6893:36)
#236    MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:6905:32)
...     Normal element mounting (487 frames)
#723    _InheritedProviderScopeElement.mount (package:provider/src/inherited_provider.dart:411:11)
...     Normal element mounting (7 frames)
#730    SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (7 frames)
#737    _NestedHookElement.mount (package:nested/nested.dart:187:11)
...     Normal element mounting (7 frames)
#744    _InheritedProviderScopeElement.mount (package:provider/src/inherited_provider.dart:411:11)
...     Normal element mounting (7 frames)
#751    SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (7 frames)
#758    _NestedHookElement.mount (package:nested/nested.dart:187:11)
...     Normal element mounting (7 frames)
#765    _InheritedProviderScopeElement.mount (package:provider/src/inherited_provider.dart:411:11)
...     Normal element mounting (7 frames)
#772    SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (7 frames)
#779    _NestedHookElement.mount (package:nested/nested.dart:187:11)
...     Normal element mounting (7 frames)
#786    SingleChildWidgetElementMixin.mount (package:nested/nested.dart:222:11)
...     Normal element mounting (35 frames)
#821    Element.inflateWidget (package:flutter/src/widgets/framework.dart:4335:16)
#822    Element.updateChild (package:flutter/src/widgets/framework.dart:3846:18)
#823    _RawViewElement._updateChild (package:flutter/src/widgets/view.dart:291:16)
#824    _RawViewElement.mount (package:flutter/src/widgets/view.dart:314:5)
...     Normal element mounting (7 frames)
#831    Element.inflateWidget (package:flutter/src/widgets/framework.dart:4335:16)
#832    Element.updateChild (package:flutter/src/widgets/framework.dart:3846:18)
#833    RootElement._rebuild (package:flutter/src/widgets/binding.dart:1354:16)
#834    RootElement.mount (package:flutter/src/widgets/binding.dart:1323:5)
#835    RootWidget.attach.<anonymous closure> (package:flutter/src/widgets/binding.dart:1276:18)
#836    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2844:19)
#837    RootWidget.attach (package:flutter/src/widgets/binding.dart:1275:13)
#838    WidgetsBinding.attachToBuildOwner (package:flutter/src/widgets/binding.dart:1088:27)
#839    WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:1070:5)
#840    WidgetsBinding.scheduleAttachRootWidget.<anonymous closure> (package:flutter/src/widgets/binding.dart:1056:7)
#844    _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
(elided 3 frames from class _Timer and dart:async-patch)
The AppService sending notification was: Instance of 'AppService'
====================================================================================================
```

I'll keep looking for a solution, but if anyone knows and can help here in the comments, I'd be very grateful.
