SchabanBo / qlevar_router

Manage you project Routes. Create nested routes. Simply navigation without context to your pages. Change only one sub widget in your page when navigating to new route.
MIT License
86 stars 22 forks source link

how to pass data from a class (screen/page) to instance of another? #34

Closed igotfr closed 3 years ago

igotfr commented 3 years ago

how to pass data from a class (screen/page) to instance of another?

something as:

QRoute(path: '/book/:id((^[0-9]\$))', builder: (Map data) => const BookDetailsScreen(data.book))
QR.to('/book/${state[item].id}', data: {book: BookModel(id: '1', title: 'Kindred', author: 'Octavia E. Butler')})
SchabanBo commented 3 years ago

Please take a look at this issue #18

igotfr commented 3 years ago
QRoute(path: '/book/:id((^[0-9]\$))', builder: () {
  QR.params['book']!.keepAlive = false;
  return BookDetailsPage(book: QR.params['book']!.valueAs<BookModel>());
})
QR.params.ensureExist('book', initValue: state[item], keepAlive: true);
QR.to('/book/${state[item].id}');