5

I am using Navigator 2.0 and I have my state stored inside the RouterDelegate so that I can have the currentConfiguration react to state changes.

This is like all examples I saw. For example:

 BookRoutePath get currentConfiguration {
    return _selectedBook == null
        ? BookRoutePath.home()
        : BookRoutePath.details(books.indexOf(_selectedBook));
  }

How can I set the property _selectedBook from some widget down the tree? I solved that in the rest of the app using Provider and passing a ChangeNotifier.

However I am not sure how to do that with RouterDelegate.

Is there a way I can access its state?

Or is there a way I can store the state in another class and still have currentConfiguration update every time _selectedBook changes?

alexlipa
  • 1,131
  • 2
  • 12
  • 27
  • I think [this](https://github.com/yeasin50/Flutter-project-Helper/blob/master/navigator2/withSengment1_detailsScreen.dart) might help you to solve the case – Md. Yeasin Sheikh Jul 27 '22 at 15:01

0 Answers0