【问题标题】:How to Wrap Each Widget with Getx obx Shows Improper use of Getx如何用 Getx 包裹每个 Widget obx 说明 Getx 使用不当
【发布时间】:2022-01-20 07:01:40
【问题描述】:

我正在尝试做 Draggable ListView Builder 并且 Listview builder 用 getx obx 包装,之后当我运行它显示错误的代码时,我用 draggablescrollsheet 包装了 listview..

【问题讨论】:

    标签: flutter dart flutter-getx


    【解决方案1】:

    此错误表示您在不包含任何.obs 变量且不会更新的小部件树的顶部使用Obx()。换句话说,您的cart 不是可观察变量。

    解决方案是让cart 变量可观察。最后,您可以使用简单的“.obs”使任何变量可观察,例如

    var cart = YourModel().obs;
    

    【讨论】:

    • 最终 cartListController = Get.put(CartListController()).obs;正在谈论这个
    • 不,在您的 CartListController 中有一个名为 cart 的变量,将其设为 .obs
    • 它已经在 .obs 中
    猜你喜欢
    • 2022-10-17
    • 2021-11-07
    • 2022-01-02
    • 2021-11-11
    • 2021-09-15
    • 1970-01-01
    • 2021-12-14
    • 1970-01-01
    • 2022-08-04
    相关资源
    最近更新 更多