Skip to content

Instantly share code, notes, and snippets.

@ritshpatidar
Created February 25, 2019 12:26
Show Gist options
  • Save ritshpatidar/07fbe4ac156d9cc292fbcaea9dd4fe1c to your computer and use it in GitHub Desktop.
Save ritshpatidar/07fbe4ac156d9cc292fbcaea9dd4fe1c to your computer and use it in GitHub Desktop.
class MyWidget extends StatefulWidget{
_MyWidgetState createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget>{
int num = 0;
@override
Widget build(BuildContext context){
return Row(
children: <Widget>[
RaisedButton(
child: Text("Count"),
color: Colors.green,
onPressed: _incrementFun
),
Text(" $num"),
],
);
}
void _incrementFun(){
setState((){
num++;
}
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment