Flutter报错:[Get] the improper use of a GetX has been detected. You should only use GetX or Obx

[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.

粗错误代码:

Flutter报错:[Get] the improper use of a GetX has been detected. You should only use GetX or Obx_第1张图片

 

正确代码:

Flutter报错:[Get] the improper use of a GetX has been detected. You should only use GetX or Obx_第2张图片

 

错误解析:Obx和GetX监听器,只适用于.obs 变量或Rx定义的变量,在普通的dart变量或方法中使用就会报这个错误

你可能感兴趣的:(Flutter学习错误集锦,flutter)