【发布时间】:2021-12-10 20:51:26
【问题描述】:
我无法使用 .obs、RxType 和 Rx() 更改任何变量的状态;
当我尝试更改它时,它会给出无法将值类型 int 分配给变量类型 RxInt 的错误。 代码如下:
class StateController extends GetxController {
late String sunrise;
late String sunset;
late int temperatureDegree;
late int maxDegree;
late int minDegree;
late double windSpeed;
late int humidity;
void updateUI(dynamic weatherDataInput) {
sunrise = weatherDataInput["current"]["sunrise"];
sunset = weatherDataInput["current"]["sunset"];
temperatureDegree = weatherDataInput["current"]["temp"];
maxDegree = weatherDataInput["daily"][0]["temp"]["max"];
minDegree = weatherDataInput["daily"][0]["temp"]["min"];
windSpeed = weatherDataInput["current"]["wind_speed"];
humidity = weatherDataInput["current"]["humidity"];
}
}
【问题讨论】:
-
你试过把update();在下面的 updateUI 上?如果它的调用更新你需要使用 getbuilder 如果不尝试在下面理解我的
标签: flutter dart state-management flutter-getx