簡體   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