Created
April 8, 2021 15:18
-
-
Save RipplesCode/49876804f1528c22bb87de4e0b9d6dc2 to your computer and use it in GitHub Desktop.
Unique ID
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:flutter_getx/my_controller.dart'; | |
import 'package:flutter_getx/next_screen.dart'; | |
import 'package:flutter_getx/student.dart'; | |
import 'package:flutter_getx/unknown_route.dart'; | |
import 'package:get/get.dart'; | |
import 'home.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
MyController myController = Get.put(MyController()); | |
@override | |
Widget build(BuildContext context) { | |
// TODO: implement build | |
return GetMaterialApp( | |
title: "State Management", | |
home: Scaffold( | |
appBar: AppBar(title: Text("State Management")), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: [ | |
GetBuilder<MyController>( | |
id: 'txtCount', | |
builder: (controller) { | |
return Text( | |
"The value is ${controller.count}", | |
style: TextStyle(fontSize: 25), | |
); | |
}, | |
), | |
GetBuilder<MyController>( | |
builder: (controller) { | |
return Text( | |
"The value is ${controller.count}", | |
style: TextStyle(fontSize: 25), | |
); | |
}, | |
), | |
SizedBox( | |
height: 10, | |
), | |
RaisedButton( | |
child: Text("Increment"), | |
onPressed: ()=>myController.increment(), | |
) | |
], | |
), | |
), | |
), | |
); | |
} | |
} |
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_getx/student.dart'; | |
import 'package:get/get.dart'; | |
import 'home.dart'; | |
class MyController extends GetxController { | |
var count = 0; | |
void increment() | |
{ | |
count++; | |
update(['txtCount']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment