Passing Arguments

Unlike other routing solutions, AutoRoute can pass any type of argument to it's routes! AutoRoute automatically detects and handles your page arguments for you, and the generated Route object will deliver all the arguments your page needs including callback functions (eg. to return results).

The following page widget will take an argument of type Book and a callback function that returns a rating value on pop.
class BookDetailsPage extends StatelessWidget {
    BookDetailsPage({('bookId') this.bookId, this.onRateBook}); 

    final int bookId;  
    final void Function(int) onRateBook;
Note: Default values are respected. Required fields are also respected and handled properly.

Now, the generated BookDetailsRoute will deliver the same arguments to it's corresponding page
    bookId: 1,
    onRateBook: (rating) { 
        // handle result
Don't forget to call the callback function as you pop the page!

Awaiting results

If you would prefer to await for the results instead of using a callback like above, you can do the following:

// In your router declaration, define the return type
  AutoRoute<int>(page: BookDetailsPage)
Then, use it in your code!
class BookDetailsPage extends StatelessWidget {
BookDetailsPage({('bookId') this.bookId}); 
// note that we took out the onRateBook callback
final int bookId;  

// In the BookDetailsPage, pop with the values you want to return
onPressed: () async {
And now in the page you are pushing from, simply use it like so
onPressed: () async {
  final int value = await context.pushRoute(BookDetailsPage(bookId: 1))
(Thanks for the snippet @jlnrrg)