Last active
May 9, 2020 15:08
-
-
Save olumidayy/837b08f073dac9a7386d15be44ea1ae3 to your computer and use it in GitHub Desktop.
This file contains 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(MaterialApp( | |
home: new Home(), | |
)); | |
} | |
class Home extends StatefulWidget { | |
@override | |
HomeState createState() => HomeState(); | |
} | |
class HomeState extends State<Home> { | |
int _counter = 0; | |
void _incrementCounter() { | |
setState(() { | |
_counter++; | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Day 9 Mobile Task'), | |
centerTitle: true, | |
), | |
body: Center( | |
child: Text( | |
'$_counter', | |
style: new TextStyle(fontSize: 40), | |
), | |
), | |
floatingActionButton: | |
Row(mainAxisAlignment: MainAxisAlignment.end, children: <Widget>[ | |
FloatingActionButton( | |
onPressed: _incrementCounter, | |
tooltip: 'Increment', | |
child: Icon(Icons.add), | |
), | |
SizedBox(width: 20), | |
FloatingActionButton( | |
onPressed: () { | |
setState(() { | |
_counter--; | |
}); | |
}, | |
tooltip: 'Decrement', | |
child: Icon(Icons.remove), | |
), | |
])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment