簡體   English   中英

我在 flutter 中收到錯誤“未處理的異常:將 object 轉換為可編碼的 object 失敗:Null”

[英]I get the error 'Unhandled Exception: Converting object to an encodable object failed: Null' in flutter

我正在嘗試將 JSON 發布到我們的 api,但即使所有值都是 NULL 並且允許為 NULL,也會繼續收到此錯誤,這是導致問題的代碼片段。

   final response = await http.post(Uri.parse('http://"api"/api/createPin'),
    body: json.encode({

      'location': Null,
      'description': Null,
      'qrcode': Null,
      'ttl': Null,
      'tier': Null,
      'type': Null,
      'user': Null,
      'images': Null,
      'viewable_users': Null
    }),
    );

我搜索了論壇和一些視頻,但都沒有解決我的問題,我不知道我做錯了什么。

Null更改為null怎么樣?

您正在尋找“空”而不是“空”。

Null 是一個無法實例化的 class 和 null 一個值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM