Skip to content

Instantly share code, notes, and snippets.

@devanshkaria88
Created January 19, 2020 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devanshkaria88/6ab692a68214134021278adf0d03146d to your computer and use it in GitHub Desktop.
Save devanshkaria88/6ab692a68214134021278adf0d03146d to your computer and use it in GitHub Desktop.
Gist Generated by DartpadGenerator by GUI at 2020-01-19 10:15:30.847014
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
void _decrementCounter() {
setState(() {
_counter--;
});
}
void _resetCounter() {
setState(() {
_counter = 0;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: ButtonBar(
children: <Widget>[
FloatingActionButton(
onPressed: _resetCounter,
backgroundColor: Colors.yellow,
child: Text('R',
style: TextStyle(
fontSize: 20.0,
color: Colors.black,
)),
),
FloatingActionButton(
onPressed: _decrementCounter,
backgroundColor: Colors.yellow,
child: Icon(
Icons.remove,
color: Colors.black,
),
),
FloatingActionButton(
onPressed: _incrementCounter,
backgroundColor: Colors.yellow,
child: Icon(
Icons.add,
color: Colors.black,
),
)
],
),
backgroundColor: Colors.black,
floatingActionButtonAnimator: FloatingActionButtonAnimator.scaling,
appBar: AppBar(
backgroundColor: Colors.yellow,
title: Text(widget.title),
),
body: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
style: TextStyle(color: Colors.white),
),
Text(
'$_counter',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 25.0,
),
),
],
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment