Skip to content

Instantly share code, notes, and snippets.

@kauemurakami
Last active July 7, 2020 05:32
Show Gist options
  • Save kauemurakami/7788d19e7dc98769f316c4021eca2635 to your computer and use it in GitHub Desktop.
Save kauemurakami/7788d19e7dc98769f316c4021eca2635 to your computer and use it in GitHub Desktop.
MyApp class counter example
class MyApp extends GetWidget {
final MyController controller = Get.put(MyController());
@override
Widget build(BuildContext context) {
return GetMaterialApp(
home: Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
GetX<MyController>(
builder: (_) => Text(_.num.toString()),
),
Container(
height: 300,
width: 345,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
FloatingActionButton(
onPressed: () => controller.increment(),
child: Icon(Icons.add, color: Colors.white),
),
SizedBox(
width: 30,
),
FloatingActionButton(
onPressed: () => controller.decrement(),
child: Icon(Icons.remove, color: Colors.white),
),
],
),
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment