Back

Document Created With Null

  • 0
  • Databases
  • Flutter
Suiii
22 Feb, 2024, 09:24
TypeScript
    try {
      print(model.toJson());
      Document result = await databases.createDocument(
      databaseId: Appwrite.kDatabaseId,
      collectionId: Appwrite.kClientsCollection,
      documentId: ID.unique(),
      data: model.toJson(),
      permissions: []
      );
      if (result.$id.isNotEmpty) {
        return ClientModel.fromJson(result.data);
      }
    } on AppwriteException catch (e) {
      print(e.toString());
    }
    return null;
  }```
TL;DR
Developers are having an issue with a document being created with null fields in Flutter form builder. The solution is to change `_formKey.currentState!.value` to `_formKey.currentState!.instantValue`. They are also seeking help with JSON encoding, monitoring what is being sent to Appwrite, and facing problems with fields becoming null after document creation.
Suiii
22 Feb, 2024, 09:25

i print out the model. and there is data

Kenny
22 Feb, 2024, 16:08

I'm not sure I understand what your issues is, can you please expand?

Suiii
23 Feb, 2024, 01:30

so I send payload to appwrite creating document. I print the model. print(model.toJson()); I clearly can see the json payload. then it also created document sucessfully. the problem is after creation new document. all fields are null.

Suiii
23 Feb, 2024, 01:30

any way to monitor what is being sent inside appwrite container

Steven
23 Feb, 2024, 03:10

They're null in the Appwrite console too?

Suiii
23 Feb, 2024, 03:11

yes, also null

Suiii
23 Feb, 2024, 03:19
Suiii
23 Feb, 2024, 03:19
Steven
23 Feb, 2024, 03:26

Can you JSON encode the map?

And also share your collection as JSON (result of get collection API call)

Suiii
23 Feb, 2024, 03:31

do you mean this

Steven
23 Feb, 2024, 03:32

JSON encode please

Suiii
23 Feb, 2024, 03:34

do you mean JSON encode the model I submit to appwrite, or return from appwrite?

Steven
23 Feb, 2024, 03:34

Both

Suiii
23 Feb, 2024, 03:36
Suiii
23 Feb, 2024, 03:36

encoding problem.

Steven
23 Feb, 2024, 03:37

Sorry what do you mean?

And it would help if you copied and pasted instead of sharing a screenshot

Suiii
23 Feb, 2024, 03:38

okay. wait

Steven
23 Feb, 2024, 03:39

I think these are 3 log messages? What are they of?

Suiii
23 Feb, 2024, 03:41

ignore that. let me make it clean

Suiii
23 Feb, 2024, 03:56

now it is okay by changing _formKey.currentState!.value to _formKey.currentState!.instantValue (flutter form builder)

Suiii
23 Feb, 2024, 03:56

but strange , i clearly print the log right here

Suiii
23 Feb, 2024, 03:58
Suiii
23 Feb, 2024, 04:00

but feel unsecure what happend.😂

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more