Flutter Navigator 2.0 made easy with go_router! Pair programming with Chris Sells, Flutter PM!

Majid Hajian · 41K views · 2021 · 1:23:53

Open on YouTube

Web developmentSoftware architecture & designtutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering Flutter routing questions about go_router, especially auth redirects and the package author's recommended patterns.

Recommended by 2 people across 2 different months, 2022 to 2023.

What it is

A 83-minute pair-programming session in which Majid Hajian and Chris Sells, the Flutter product manager and author of go_router, refactor a Flutter app from Navigator 1.0 to Navigator 2.0 using the go_router package. It covers nested routes, web URL strategies, auth redirects, deep and dynamic links, and route debugging.

What people said

Recommends Behnam · 2022-06 · Stack Overflow · on “passing Auth data with go_router”

according to this video Chris Sells author of the package recommend to create a class that holds auth data and then share this data within router class : [this video]

Recommends Sayyid J · 2022-08 · Stack Overflow · on “Should I pass the google sign-in variables to other class?”

its called inherited widget, there is a lot method to make your entire app authenticated, not just one class. make a stream builder, listen firebase_auth.authStateChanges() or you can use a package ( state management ) : like flutter_bloc [LINK] or i prefer goRouter [LINK] check this video, its chris itself explain how to use it [this video] , its even better; work at flutter web too take look at mine for your reference : import 'dart:ui'; import 'package:cms_prototype/auth/auth.dart'; import 'package:cms_prototype/home/home.dart'; import 'package:cms_prototype/login/login.dart'; import 'package:cms_prototype/theme.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter/

Cites Behnam · 2022-06 · Stack Overflow · on “Flutter go_router package redirects not works properly”

according to this official video from author of go_router package : Flutter Navigator 2.0 made easy with go_router [this video] and this Flutter Navigator 2.0: Using go_router [LINK] complete guide , I implemnted go_router in my app. However, I'm having a strange problem. Everything works properly the first time I run my app. I can fetch user information from the server and send them to the home page. However, I'm getting an issue regarding fetching data after restarting my app. Would you please tell me why I'm receiving this error? this my main.dart : void main() async { WidgetsFlutterBinding.ensureInitialized(); final sharedPrefs = await SharedPreferences.getInstance(); runApp(MyApp(sharedPrefs

Cites Mindmax · 2023-02 · Stack Overflow · on “onGenerateRoute gets called multiple times but the navigator only builds once flutter”

So after further investigation the multiple calls of the rautes are due to the / notation. So basically I removed the /auth from all the routes to prevent the multiple calls. Also I set the initial route and the one that leads to AuthOverviewPage to "/" (so they are default routes). Now the routes and its Widgets are only called once. However I decided to switch to go_router [this video] as it fits my usecases and also seems to be a "newer" pattern.