I’d like to make a map observable in my controller. But when I wrap the widget that’s using the observable map with Obx(), I get the runtime error that says “[Get] the improper use of a GetX has been detected. You should only use GetX or Obx for the specific widget that will be updated.”
But I thought I had used Obx for the specific widget to be updated.
class PaintingControllerX extends GetxController {
final gridImages = <ui.Image?>[].obs;
}
class PaintingPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
var controller = Get.put<PaintingControllerX>(PaintingControllerX());
return Scaffold(
body: Obx(() => GridWidget(controller.gridImages)), // ERROR
);
}
}
I saw in a different StackOverflow question (Obx widget throws an error) that the problem was resolved by calling the value property on the observed object. But RxMap.value is protected, I can’t use it here. I also noticed there’s a toList() method on RxList, but there’s no corresponding toMap() on RxMap.
How do I use a RxMap with Obx?