Skip to content

Instantly share code, notes, and snippets.

@olumidayy
Last active May 9, 2020 15:08
Show Gist options
  • Save olumidayy/837b08f073dac9a7386d15be44ea1ae3 to your computer and use it in GitHub Desktop.
Save olumidayy/837b08f073dac9a7386d15be44ea1ae3 to your computer and use it in GitHub Desktop.
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