How to run flutter to a specific route

Cover image for Flutter tip (#4): run a Flutter app to a specific route

Have you ever wanted to run your Flutter app straight to a specifically named route? yes, it is possible.

This is helpful when you:

  • Want to test a specific page in your app and you don’t want to run the whole app and navigate to that page by yourself.
  • Want to test deep link in your Flutter app.
  • (other) you may need it for many other use-cases 🙂

Show me the code

All you need to do is to run the flutter command with the --route parameter:

pedromassago$ flutter run --route /routeName

The --route parameter expects a string that is the route name that will be used to start your application with. In the case above the app will start with the /routeName page in your screen.

Notes

This feature is only available for Android devices at the time this post was written. There is an open issue to bring support for another platform like iOS at flutter/flutter/issues/4703. If you want this feature on iOS you can thumbs up the issue to get it fixed sooner.

References

https://res.cloudinary.com/practicaldev/image/fetch/s–giVox16d–/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/i/qiq2iniotkkar690160j.jpeg

Leave a Comment

Your email address will not be published. Required fields are marked *