Created
May 23, 2018 12:07
-
-
Save chetdeva/9e39d1c7dad94fe5eb0b0f02b383cc17 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(new MyApp()); // Application | |
class MyApp extends StatelessWidget { // MainActivity | |
@override | |
Widget build(BuildContext context) { // onCreate | |
return new MaterialApp( | |
title: 'Flutter Demo', // app_name | |
theme: new ThemeData( // AppTheme | |
primarySwatch: Colors.blue, | |
), | |
home: new MyHomePage(title: 'Flutter Demo Home Page'), // NavHost | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { // Fragment | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
_MyHomePageState createState() { | |
return new _MyHomePageState(); // setup MVP/MVVM | |
} | |
} | |
class _MyHomePageState extends State<MyHomePage> { // Presenter/ViewModel | |
int _counter = 0; | |
void _incrementCounter() { | |
setState(() { // invalidate(), render() (MVI) | |
_counter++; | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( // CoordinatorLayout : appBar, body, fab | |
appBar: new AppBar( | |
title: new Text(widget.title), // TextView | |
), | |
body: new Center( // <center>child</center> | |
child: new Column( // LinearLayout with vertical orientation (horizontal: Row) | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
new Text( | |
'You have pushed the button this many times:', | |
), | |
new Text( | |
'$_counter', | |
style: Theme.of(context).textTheme.display1, | |
), | |
], | |
), | |
), | |
floatingActionButton: new FloatingActionButton( | |
onPressed: _incrementCounter, | |
tooltip: 'Increment', | |
child: new Icon(Icons.send), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment