Skip to content

Instantly share code, notes, and snippets.

@siumhossain
Last active May 28, 2021 16:01
Show Gist options
  • Save siumhossain/4bbae3b235060aac70edd685660883c2 to your computer and use it in GitHub Desktop.
Save siumhossain/4bbae3b235060aac70edd685660883c2 to your computer and use it in GitHub Desktop.
Getx reactive state management counter app
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