How to use obs before return widget

Viewed 53

I want to use obs before return any widget, how to set this observable action?

class TestController extends GetxController {
  var condition = ''.obs;
}

class TestScreen extends StatelessWidget {
  final TestController testController = Get.find();
  @override
  Widget build(BuildContext context) {
    // How to set the if conditional statement in obx?
    if (testController.condition.value != '') {
      ...
    }

    return ...
  }
}
1 Answers
class TestScreen extends StatelessWidget {
 final TestController testController = Get.find();
 @override
 Widget build(BuildContext context) {
 // How to set the if conditional statement in obx?
return Obx((){
   if (testController.condition.value != '') {
   return ...
  }
  return ...
 });
}

That's how you use it.

Related