How to observe an enum? #1069
Unanswered
danieleelli
asked this question in
Q&A
Replies: 1 comment
-
class Page2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
final controller = Get.put(Page2Controller());
return Scaffold(
appBar: AppBar(title: Text('Page2')),
body: Container(
child: Obx(
() => Center(
child: Text(controller.status.value == Status.running
? 'running'
: 'not running'),
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () => controller.run(),
child: Icon(Icons.add),
),
);
}
}
enum Status { none, running, stopped, paused }
class Page2Controller extends GetxController {
final status = Status.none.obs;
//final Rx<Status> status = Status.none.obs;
run() {
status.value = Status.running;
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I need to observe an enum, but I can't find how to do it in controller. Anyone know it, please?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions