[英]GetxController structure
class Controller extends GetxController {
int currentIdx = ''.obs;
void updateInt(int idx) {
currentIdx = idx.obs;
}
}
這是我的控制器。 現在我把這一行作為一個小部件來獲取 idx 值並立即分配給 currentIdx 值:
Controller().updateInt(idx);
但是 .obs 行在當前結構中給出了錯誤。
當我更改控制器時:
class Controller extends GetxController {
RxInt currentIdx = 0.obs;
void updateInt(RxInt idx) {
currentIdx = idx;
}
}
這次 Controller().updateInt(idx); 給出錯誤。 (RxInt 不兼容 int 值)
我該如何處理?
您需要像這樣聲明和使用:
RxInt currentIdx = 0.obs;
void updateInt(int id) {
currentIdx.value = id;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.