Search code examples
flutterdartandroid-contentprovider

Can I store a PageController inside a Provider


I have a scenario where I need to use the methods of a particular PageController in another class, and in this situation its not easy to pass, so I was wondering if anyone knows if its a terrible idea to store a PageController inside my provider class using ChangeNotifier mixin?

If it is, would it maybe be fine to store just a function that points to something like provider.someFunction = (int index) { controller.jumpToPage(index) }; so that I can use that in another place?


Solution

  • Yes, you can store a PageController in a Provider.