Bacancy Technology
Bacancy Technology represents the connected world, offering innovative and customer-centric information technology experiences, enabling Enterprises, Associates and the Society to Rise™.
12+
Countries where we have happy customers
1050+
Agile enabled employees
06
World wide offices
12+
Years of Experience
05
Agile Coaches
14
Certified Scrum Masters
1000+
Clients projects
1458
Happy customers
Artificial Intelligence
Machine Learning
Cloud Services
AWS
Azure
Google Cloud
Salesforce
Microsoft
SAP
July 31, 2023
If you want to use setState then you should use StatefulWidget instead of a StatelessWidget, I am assuming you are trying to setState on a stateless widget.
Below is the example to explain you how to use setState with stateful widget:
class HomePage extends StatefulWidget { const HomePage({Key? key}) : super(key: key); @override State<HomePage> createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { int incrementValue = 0; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, body: InkWell( onTap: () { setState(() { //write code here incrementValue++; }); }, child: Text("Press Here $incrementValue"), )); } }