I want to use the _count variable in another widget. I can't access _count variable with provider
class Hamburger extends StatefulWidget {
const Hamburger({super.key});
@override
State<Hamburger> createState() => _HamburgerState();
}
class _HamburgerState extends State<Hamburger> {
int _count = 1;
The issue is that you are trying to access _count in a separate class without providing context to the Provider. To access the value of _count using Provider, you need to wrap the _HamburgerState widget in a ChangeNotifierProvider and expose _count as a listenable property.
This is an example: