Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

Explanation and question about "Type-safe routes" and if there are plans to implement them #159

Answered by csells
jacob-emery asked this question in Q&A
Discussion options

You must be logged in to vote

Type safety is the idea that the compiler catches your mistakes instead of waiting until run-time. For example, if you have the following route:

GoRouter(path: '/family/:fid', ...)

and navigate to it w/o the 'fid' parameter:

context.go('/family'); // oops. forgot the fid param

this code will compile just fine. You won't see the exception until run-time because you should've called it like so:

context.go('/family', params: {'fid': 'f2'});

However, if this was a typesafe route, you could imagine calling it like so:

familyRoute.go(context, fid: 'f2');

In this case, the compiler would let you know if you forgot to add the fid parameter.

The idea of using a code generator in Dart is to be able…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jacob-emery
Comment options

Answer selected by jacob-emery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants