Skip to content

Instantly share code, notes, and snippets.

@prasadsunny1
Created August 18, 2019 08:38
Show Gist options
  • Save prasadsunny1/0968048aa1622fae3811a527b1a6d316 to your computer and use it in GitHub Desktop.
Save prasadsunny1/0968048aa1622fae3811a527b1a6d316 to your computer and use it in GitHub Desktop.
main.dart
import "package:flutter/material.dart";
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
int count = 0;
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(brightness: Brightness.dark),
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text('Apanu App'),
actions: <Widget>[
Center(
child: Text(count.toString()),
),
IconButton(
onPressed: () {
setState(() {
count++;
});
},
icon: Icon(Icons.arrow_upward),
),
IconButton(
onPressed: () {
setState(() {
count--;
});
},
icon: Icon(Icons.arrow_downward),
),
IconButton(
onPressed: () {
setState(() {
count = 0; // reset
});
},
icon: Icon(Icons.refresh),
),
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Text('Press Up Arrow To Increment'),
Text('Press Down Arrow To Decrement'),
Text('Press Reset To Reset'),
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment