I am using the Provider
-Package to store some data in my app. For that I also have a Service-Class
where I define several functions. Now the thing is that I need these two values in almost every function:
Year currentYear =
Provider.of<CurrentlySelectedProvider>(context, listen: true)
.currentYear;
Month currentMonth =
Provider.of<CurrentlySelectedProvider>(context, listen: true)
.currentMonth;
Right now I am simply calling this inside every method of the class. But that seems a bit stupid. Is there a way to define those two values in my class somewhere so I can access them with a simple variable and I don't have to call the. whole thing over and over again?
I hope my problem is clear. Let me know if you need any more info!