繁体   English   中英

GetxController 不是 GetxController 的子类型

[英]GetxController is not subtype of GetxController

我目前正在开发电子商务应用程序,其中我将底部导航放在主页上,每个图标上都有徽章,在这里,当我将 cartItems 计数器徽章放在 CartIcon 上时,在主页上使用了 cartcontroller 的依赖注入(我已经使用 Getbuilder 和 Obx 尝试了这两种方法),但因为我也使用底部导航必须通过cartscreen 导航我的应用程序,它也具有cartcontroller 依赖性,出现以下错误。就像我不能在小部件树的父和子小部件中放置相同的控制器。 PS:我也试过 Get.find() 用于购物车屏幕。 这是错误:

════════ Exception caught by widgets library ═══════════════════════════════════
The following _CastError was thrown building Builder:

    type 'CartController' is not a subtype of type 'CartController' in type cast where
    CartController is from sourcepath/controllers/cartController.dart
    sourcepath/controllers/cartcontroller.dart:1
    CartController is from sourcepath/controllers/cartcontroller.dart

到目前为止,我已经了解到您有两种不同的控制器,一种是carController ,另一种是carcontroller (注意骆驼外壳),因此从技术上讲,您不能将它们组合在一起。 请在您的代码中检查。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM