0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【備忘録】freezedでDefault値指定すると型の書き忘れに気づかないがち問題

Posted at

Flutter × freezed × Firestore で開発している最中、以下のエラーでFirestoreにデータを追加できなかったのを解決したので備忘録を残します。

エラー

[cloud_firestore/invalid-argument] Function setDoc() called with invalid data. Unsupported field value: a custom ContentType object (found in document XXXX/XXXX)

原因

freezed使っててDefault値指定してたりすると、ウッカリ型書き忘れてても警告もエラーも出してくれないしパッと見で違和感がないので、書き忘れに気づかないがち。

image.png

今回の場合、contentTypeの型ContentTypeを書き漏らしていた。
型を追加してdart run build_runner builldすると無事firestoreへの書き込みができるようになった。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?