Im trying to apply Getx State Management to update my screen(maybe responsive?),
I have read official getx github documents. and this is what I tried.
1. set variables that I want make it responsive to .obs
<e.g 1>
List blueBan = List<String>.filled(5, champIcon, growable: false).obs;
List redBan = List<String>.filled(5, champIcon, growable: false).obs;
==================================================================================================
2. set Widget to Obx(()=> Widget) that I want update (update like using setState method)
<e.g 2>
Widget banContainer(List banList, String team, int n) {
return Container(
...
child: Obx(
() => DragTarget<String>(
onWillAccept: (value) {
banTemp = value;
return true;
*variable banList is reference of blueBan,redBan.
I'm using it like banContainer(blueBan, 'blue', 0)
↓ this is error message what I've got.
════════ Exception caught by widgets library ═══════════════════════════════════
The following message was thrown building Obx(has builder, dirty, state: _ObxState#1202f):
[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.
If you are seeing this error, you probably did not insert any observable variables into GetX/Obx
or insert them outside the scope that GetX considers suitable for an update
(example: GetX => HeavyWidget => variableObservable).
If you need to update a parent widget and a child widget, wrap each one in an Obx/GetX.
The relevant error-causing widget was
Obx
lib\…\ui\BanPick.dart:230
When the exception was thrown, this was the stack
#0 RxInterface.notifyChildren
package:get/…/rx_core/rx_interface.dart:29
#1 _ObxState.build
package:get/…/rx_flutter/rx_obx_widget.dart:54
#2 StatefulElement.build
package:flutter/…/widgets/framework.dart:4691
#3 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4574
#4 StatefulElement.performRebuild
package:flutter/…/widgets/framework.dart:4746
...
════════════════════════════════════════════════════════════════════════════════
Nevertheless I inserted .obs on my List variable, it says "If you are seeing this error, you probably did not insert any observable variables into GetX/Obx"
thanks for reading.
You have to use RxList for obserble then it will work in obx otherwise you have to use getbuilder and call the update() for ui changes