Mt Khalifa
Mt Khalifa

Reputation: 498

i want to add to the default value

i want to add 10 to $counter. It works when i change it from counter + 10 to counter++ but it will increment by 1

int counter = 0;
   
 _incrementCounter10() {
    setState(() {
      counter + 10;
    });
  }

Text('$counter')

 InkWell(onTap: (){_incrementCounter10;})

Upvotes: 0

Views: 171

Answers (1)

Bintang Lazuardi
Bintang Lazuardi

Reputation: 166

To add 10 in your $counter variable you can edit your setState() function from

counter + 10;

to

counter += 10;

Upvotes: 2

Related Questions