Member-only story

Flutter Fast, Flutter Far — Issue #2

Code on the Rocks
4 min readSep 18, 2021

--

Declarative Routing Makes it Easy

This article was copied from the Flutter Fast, Flutter Far newsletter. Subscribe for better formatting and weekly knowledge!

Take a simple mobile application, introduce the concept of users, and you now have a complicated mobile application. It might seem like a simple task at first thought but…think again. With users you will need to:

  • Structure your database to query by user ID
  • Manage users’ credentials
  • Check users’ permissions on database interactions
  • Verify users’ authentication statuses
  • Route users dynamically based on their authentication status

In this letter I’m going to dive into the last two points on this list. Each time a user opens your app, you need to determine what they should see.

  • If the user is new, they should see options to sign in or sign up.
  • If the user signed up but didn’t complete onboarding, they should be sent back to your onboarding workflow.
  • If a user is logged in and finished with onboarding, they should be sent to the home screen.

In each of these scenarios, we also need to prevent the user from accidentally seeing a screen that’s not meant for them (for example, we shouldn’t just “push” the user to the home screen if they are logged in because they might hit the back button and see the sign in/sign up…

--

--

No responses yet