Skip to main content
The Dynamic Flutter SDK integrates seamlessly with go_router for navigation and route protection based on authentication state. This guide demonstrates how to set up go_router with Dynamic authentication flows.

Overview

The integration involves creating an AuthNotifier that bridges Dynamic SDK streams into a ChangeNotifier that go_router can use to automatically handle route redirects based on authentication state.

Complete Implementation

1. AuthNotifier Setup

First, create an AuthNotifier class that listens to Dynamic SDK authentication streams:

2. Go Router Configuration

Set up your go_router with the AuthNotifier and route protection:

3. Dynamic SDK Initialization

Initialize the Dynamic SDK in your main() function:

Route Protection Patterns

Authentication States

The AuthNotifier manages three distinct states:
  • AuthPhase.loading: SDK is initializing or user state is being determined
  • AuthPhase.unauthenticated: SDK is ready but no user is authenticated
  • AuthPhase.authenticated: SDK is ready and user is authenticated

Redirect Logic

The redirect function automatically handles navigation based on authentication state:
Navigate programmatically using go_router methods:

Integration with Dynamic UI

Login View

Loading View

Live Example

For a complete working example, check out the Dynamic Flutter Example App which demonstrates this exact integration pattern with additional features like wallet management and web3dart integration. You can read more about go_router in the official documentation.
Last modified on January 26, 2026