Please help.I use flutter and GetX.
How to set enum variable observaible? enum MyEnumType {open,close}; var _myEnumTypeVar = MyEnumType.open.obs;
Please help.I use flutter and GetX.
How to set enum variable observaible? enum MyEnumType {open,close}; var _myEnumTypeVar = MyEnumType.open.obs;
I think you can use the Rx constructor with Type parameter:
class EnumX extends GetxController {
Rx<MyEnum> myEnum = Rx<MyEnum>(MyEnum.open);
}
enum MyEnum {
open,
close
}
Example for using enum for @chichi comment/question:
EnumX ex = Get.put(EnumX());
print('enum: ${ex.myEnum.value}');
ex.myEnum(MyEnum.close);
//ex.myEnum.value = MyEnum.close; ← same as this
print('enum: ${ex.myEnum.value}');