Created
January 19, 2020 04:45
-
-
Save devanshkaria88/5ac919880db48680935c7917428db987 to your computer and use it in GitHub Desktop.
Gist Generated by DartpadGenerator by GUI at 2020-01-19 10:14:57.931696
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(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