Last active
July 7, 2020 05:32
-
-
Save kauemurakami/7788d19e7dc98769f316c4021eca2635 to your computer and use it in GitHub Desktop.
MyApp class counter example
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
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