Last active
May 28, 2021 16:01
-
-
Save siumhossain/4bbae3b235060aac70edd685660883c2 to your computer and use it in GitHub Desktop.
Getx reactive state management counter app
This file contains hidden or 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'; | |
| import 'package:get/get.dart'; | |
| void main() { | |
| runApp(MyApp()); | |
| } | |
| class MyApp extends StatelessWidget { | |
| var count = 0.obs; | |
| void increment(){ | |
| count++; | |
| } | |
| @override | |
| Widget build(BuildContext context) { | |
| return GetMaterialApp( | |
| home: Scaffold( | |
| body: Column( | |
| children: <Widget>[ | |
| Obx(()=> | |
| Text('value $count',style: TextStyle( | |
| fontSize: 18, | |
| color: Colors.black, | |
| ),), | |
| ), | |
| ElevatedButton(onPressed: (){ | |
| increment(); | |
| }, child: Text( | |
| 'click', | |
| style: TextStyle( | |
| color: Colors.black, | |
| fontSize: 18.0, | |
| ), | |
| ),), | |
| ], | |
| ), | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment