I am getting ' [Get] the improper use of a GetX has been detected.' error in flutter. I'm using getx.
[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.
My code is :
RxList<String> selectedBanks = <String>[].obs;
RxList<String> banksSHTextList = <String>[].obs;
Obx(
()=> DropDownMultiSelect(
onChanged: (List<String> x) {
RxList<String> rxList = x.obs;
_dbsController.selectedBanks = rxList;
},
isDense: false,
options: _dbsController.banksSHTextList,
selectedValues: _dbsController.selectedBanks,
whenEmpty: 'Seçiniz',
),
),
If you want use Obx
widget, you have to use Rx
variable widget which depend any variable.
Solution
RxList<String> selectedBanks = <String>[].obs;
RxList<String> banksSHTextList = <String>[].obs;
Obx(()=> DropDownMultiSelect(
onChanged: (List<String> x) {
_dbsController.selectedBanks =x.obs;
},
isDense: false,
options: _dbsController.banksSHTextList.value,
selectedValues: _dbsController.selectedBanks.value,
whenEmpty: 'Seçiniz',
),)