Advertisement
khoi01

simple flutter

Nov 4th, 2020
1,053
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.78 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() => runApp(MyApp());
  4.  
  5. class MyApp extends StatelessWidget {
  6.   @override
  7.   Widget build(BuildContext context) {
  8.     return MaterialApp(
  9.       title: 'Flutter Demo',
  10.       theme: ThemeData(
  11.         primarySwatch: Colors.blue,
  12.       ),
  13.       home: MyHomePage(
  14.         title: "watever",
  15.       ),
  16.     );
  17.   }
  18. }
  19.  
  20. class HomePageKhoi extends StatelessWidget {
  21.   const HomePageKhoi({Key key}) : super(key: key);
  22.  
  23.   @override
  24.   Widget build(BuildContext context) {
  25.     return Scaffold(
  26.       backgroundColor: Colors.green,
  27.       appBar: AppBar(
  28.         title: Text("Wan is here"),
  29.       ),
  30.       body: Container(
  31.         child: Text("hello world"),
  32.       ),
  33.     );
  34.   }
  35. }
  36.  
  37. class MyHomePage extends StatefulWidget {
  38.   MyHomePage({Key key, this.title}) : super(key: key);
  39.  
  40.   final String title;
  41.  
  42.   @override
  43.   _MyHomePageState createState() => _MyHomePageState();
  44. }
  45.  
  46. class _MyHomePageState extends State<MyHomePage> {
  47.   int _counter = 0;
  48.  
  49.   void _incrementCounter() {
  50.     setState(() {
  51.       _counter++;
  52.     });
  53.   }
  54.  
  55.   @override
  56.   Widget build(BuildContext context) {
  57.     return Scaffold(
  58.       appBar: AppBar(
  59.         title: Text(widget.title),
  60.       ),
  61.       body: Center(
  62.         child: Column(
  63.           mainAxisAlignment: MainAxisAlignment.center,
  64.           children: <Widget>[
  65.             Text(
  66.               'You have pushed the button this many times:',
  67.             ),
  68.             Text(
  69.               '$_counter',
  70.               style: Theme.of(context).textTheme.display1,
  71.             ),
  72.           ],
  73.         ),
  74.       ),
  75.       floatingActionButton: FloatingActionButton(
  76.         onPressed: _incrementCounter,
  77.         tooltip: 'Increment',
  78.         child: Icon(Icons.add),
  79.       ),
  80.     );
  81.   }
  82. }
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement