An example on how to use Riverpod + GoRouter

Overview

go_router_example

A simple login / logout example that showcases the use of Riverpod with GoRouter. This example exploits the usage of ref.listen and a ChangeNotifier to update the Router's decisions.

Please consider starring this mini-repo if you found it useful. If you didn't, or if you want to contribute in any way, a discussion about improving this example can be found here.

Comments
  • Store Firebase User Globally using StateProvider

    Store Firebase User Globally using StateProvider

    Excellent example! I'm a newbie in Riverpod. Anyone has any idea how to store the user gotten from firebase after authentication such that I can access the user (including user firebase id) within my app? Thanks

    opened by myhendry 5
  • Suggested approach with more than one provider to watch?

    Suggested approach with more than one provider to watch?

    I have multiple providers that I need to watch to determine whether redirects are needed (e.g. auth provider, email verification provider, etc.). In that scenario using the new sync example, my screen visibly flashes when rebuilding multiple times. I did read the README section about how most rebuilds aren't what they seem, but it seems the current approach may only be meant for a single provider at a time? When I remove everything but a single auth provider the behavior is as expected and there is no flickering or visible rebuilding. Is there a suggested approach or any examples showing how to watch more than one provider? Should I create a combined provider that has every bit of state/property the router needs for its redirect? Thanks so much for making this repo!

    opened by spakanati 3
  • Stupid question about private variables

    Stupid question about private variables

    Hi @lucavenir

       ...
        redirect: router._redirect, // All the logic is centralized here
        routes: router._routes,
       ...
    

    How come private variable _redirect and _routes are accessible?

    Thanks Jas

    opened by jascodes 2
  • Custom/No Transitions

    Custom/No Transitions

    Hey thanks for that repo 👍

    But a simple question, how can I customize or even disable the route transitions? I did not found any information beside using GoRoute but nothing with GoRouteData.

    question 
    opened by appinteractive 1
  • Using the Global Key for firebase example

    Using the Global Key for firebase example

    Hey mate, love the project. It's working flawlessly for my work. I do have one question about it through, and not necessarily a bug report. How does one call the Global Key to navigate?? I'm creating a web app and I want to have simple navigation tabs in the app bar that take the user to the specified page. For example

    return AppBar(
       title: TextButton(
         onPressed: isUserSignedIn
             ? () => key.currentState!.pushNamed('/dashboard')
             : () {
                 key.currentState!.pushNamed('/preloginhome');
               },
         child: Text(
           'home',
    
           ),
         ),
       ),
    

    will give me an errorNavigator.onGenerateRoute was null, but the route named "/preloginhome" was referenced. How can we access the routes we put in the routerProvider globally?

    opened by hdbookie 1
  • Changed the main example with code gen tools

    Changed the main example with code gen tools

    Addresses several issues pointed out from the community onto complete_example, such as:

    1. Unnecessary starting rebuilds
    2. Scalability issues (e.g. "how do I add more listeners?")
    3. Exploits code generation extensively
    4. Allows for more stable APIs (touching this example will feel less risky
    5. Uses a ProviderObserver, which allows for better understanding of the example

    Yes, the code is still (loosely) tested.

    You'll notice big changes with respect the old example. Furthermore, the new Notifier API is exploited, so at a first glance it seems like I've made a step backwards, but it's actually the other way around.

    As soon as you'll try this, you'll feel more "in control" of what's going on. Just try this out and let me know what you think.

    Potentially solves #7 and resolves what #5 was trying to solve.

    enhancement 
    opened by lucavenir 0
  • Extend to include support for Firebase dynamic links

    Extend to include support for Firebase dynamic links

    I'm trying to extend your example to support firebase dynamic links, both on the Web as well as in Android. However, I'm struggling to get it working in conjunction with authentication. I tried to implement it as shown in this tutorial which also uses go_router + riverpod to get dynamic links working, but I have only been able to get it working on Android.

    On the web - as soon as I implement the providers as shown in your example, whenver I load a link fresh it makes a cold start of the application and ends up redirecting me to my main page (after I briefly see the correct location). Any hints on that?

    opened by sischnei 1
Releases(GoRouterV4)
Owner
Luca Venir
🐦 Flutter, Dart 📲 Mobile Development 🌐 Svelte Kit 🏛️ SW Architecture
Luca Venir
Riverpod Messages Listener: A message notification listener for apps build with Riverpod

Riverpod Messages Listener Hello all, this is the home page of riverpod_messages package, a message notification listener for apps build with Riverpod

Fabrizio Tognetto 4 Dec 8, 2022
This is an example project for the article about implementing clean architecture in flutter with riverpod and supabase as backend service.

The Example This is an example how to implement clean architecture with domain driven design and riverpod in flutter projects. Getting Started Rename

Volodymyr Hodiak 45 Dec 30, 2022
Lottie-package-example-Flutter - A simple example about lottie package in Flutter

Lottie Package example - Flutter ScreenShot ⚠️ Essential Packages lottie: ^1.2.1

AmirHossein Bayat 3 Dec 7, 2022
Smooth-Page-Indicator-Example-Flutter - A simple example about smooth page indicator in Flutter

Smooth Page Indicator Example - Flutter Screenshots ⚠️ Essential Packages smooth

AmirHossein Bayat 6 Dec 7, 2022
Flutter Cryptocurrency App with Riverpod & Freezed + Dio for API REST

Flutter Crypto APP Complete Flutter Application with Riverpod & Freezed + Dio for API REST. Features API REST (CryptoWatch) Linear Graph View (Hour, D

Salvador Valverde 312 Jan 2, 2023
Starting template for a new Flutter project. Using clean architecture + Riverpod.

flutter_project_template_riverpod Installation Add Flutter to your machine Open this project folder with Terminal/CMD Ensure there's no cache/build le

Bahri Rizaldi 39 Dec 27, 2022
A boilerplate project for Flutter using RiverPod, Dio, auto_route

Flutter Boilerplate A boilerplate project for Flutter using RiverPod, Dio, auto_route, Freezed and generated with very_good_cli. This is a very simple

Gildo Jr 9 Dec 9, 2022
Flutter theme demo using riverpod and shared preferences

flutter_theme_demo A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you start

Andree Yosua 0 Dec 27, 2021
Shopify Tag and Product Management App using Flutter and Riverpod State Management

Myshopify App A Simple Flutter Application project to get List of Tags, Products and Product Details from shopify https://shopicruit.myshopify.com/adm

Idowu Tomiwa 5 Nov 12, 2022
Complete Flutter Application with Riverpod & Freezed + Dio for API REST

Flutter Crypto APP Complete Flutter Application with Riverpod & Freezed + Dio fo

Xtenso 32 Dec 26, 2022
INSTAGRAM CLONE - FRONTEND FLUTTER 2.5 + GRAPHQL + RIVERPOD

INSTAGRAM CLONE - FRONTEND FLUTTER 2.5 FLUTTER + GRAPHQL + RIVERPOD USER LOGIN SEE PROFILE EDIT PROFILE FOLLOW USER UNFOLLOW USER TOTAL FOLLOWING TOTA

Rui Paulo Calei 6 Sep 2, 2022
Bringing back contex.read and context.watch for riverpod

This package brings back the context extensions for riverpod that were discontinued in version 1.0.0. To read any provider, do context.read(myProvider

Kilian Schulte 2 Sep 28, 2022
A flutter project containing riverpod, flutter_lints, hive, easy_translations and more!

Flutter Production Boilerplate Riverpod A flutter project containing riverpod, flutter_lints, hive, easy_translations and more! This repository is the

Andreas Feichtinger 46 Dec 27, 2022
A demonstration of using Riverpod for dynamic locale switching in-app, with persistence.

Riverpod Localization A demonstration of using Riverpod for dynamic locale switching in-app, with persistence. How It Works Fallback Locale: Declared

Dominique Rwema Bagirishya 30 Oct 6, 2022
Multiplayer tictactoe game made in Flutter with nodejs and socket.io and using riverpod for state management

TicTacToe Game A Multiplayer TicTacToe Game- Works on Android, iOS and Web. Features Create/Join Room Play Realtime Display Points Round & Game Winner

Utsav Ghimire 5 Oct 18, 2022
A Flutter application that allows interacting with Pokemons, built using Clean Archtitecture structure and riverpod as state management.

pokedex Welcome to the Pokedex project! Getting Started Instructions to run: This project uses flutter version 3.0.3, Make sure you have that version

null 25 Nov 22, 2022
Riverpod State Mgmt for Flutter. StateProviders, StateNotifierProviders, FutureProviders, StreamProviders, autodisposed and families, and everything in-between.

Flutter Riverpod Learning/Reference zone A Null-Safety flutter project acting as a learning/code reference zone Based on Riverpod (v1/v2) Page Transit

Lexx YungCarter 8 Dec 24, 2022
This is a practical guide to MVVM architecture in flutter with riverpod for state management.

flutter_mvvm This project is a practical guide to MVVM pattern in flutter with Riverpod. Install flutter Get your APIKEY from https://api.openweatherm

Augustine Victor 3 Jan 1, 2023