joaopaulofcc

Untitled

Dec 2nd, 2020
778
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'package:flutter_mobx/flutter_mobx.dart';
  2. import 'package:mobxteste/counter.dart';
  3. import 'package:flutter/material.dart';
  4.  
  5. void main() {
  6.   runApp(MyApp());
  7. }
  8.  
  9. final counter = Counter();
  10.  
  11. class MyApp extends StatelessWidget {
  12.   @override
  13.   Widget build(BuildContext context) {
  14.     return MaterialApp(
  15.       title: 'Flutter Demo',
  16.       theme: ThemeData(
  17.         primarySwatch: Colors.blue,
  18.         visualDensity: VisualDensity.adaptivePlatformDensity,
  19.       ),
  20.       home: MyHomePage(title: 'Flutter Demo Home Page'),
  21.     );
  22.   }
  23. }
  24.  
  25. class MyHomePage extends StatefulWidget {
  26.   MyHomePage({Key key, this.title}) : super(key: key);
  27.  
  28.   final String title;
  29.  
  30.   @override
  31.   _MyHomePageState createState() => _MyHomePageState();
  32. }
  33.  
  34. class _MyHomePageState extends State<MyHomePage> {
  35.   @override
  36.   Widget build(BuildContext context) {
  37.     return Scaffold(
  38.       appBar: AppBar(
  39.         title: Text(widget.title),
  40.       ),
  41.       body: Center(
  42.         child: Column(
  43.           mainAxisAlignment: MainAxisAlignment.center,
  44.           children: <Widget>[
  45.             Text(
  46.               'You have pushed the button this many times:',
  47.             ),
  48.             Observer(
  49.               builder: (_) => Text(
  50.                 '${counter.value}',
  51.                 style: Theme.of(context).textTheme.headline4,
  52.               ),
  53.             ),
  54.           ],
  55.         ),
  56.       ),
  57.       floatingActionButton: FloatingActionButton(
  58.         onPressed: counter.increment,
  59.         tooltip: 'Increment',
  60.         child: Icon(Icons.add),
  61.       ),
  62.     );
  63.   }
  64. }
RAW Paste Data