Created
August 18, 2019 08:38
-
-
Save prasadsunny1/0968048aa1622fae3811a527b1a6d316 to your computer and use it in GitHub Desktop.
main.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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