Back

[SOLVED] Appwrite double attribute value is an int

  • 0
  • Flutter
Infinil
6 Sep, 2023, 19:51

I noticed that doubles like 8.0 are "int" when the document is fetched in flutter dart

TL;DR
The issue was that when fetching a document in Flutter Dart from Appwrite, double attribute values like `8.0` were being treated as integers. The solution is to cast the value as a number type and then use `toDouble()` to get the correct double value. This behavior is expected because JSON always represents integers as whole numbers and not with decimal points.
Infinil
6 Sep, 2023, 19:52

is this expected behaviour?

Drake
6 Sep, 2023, 22:06

yes, because JSON will always be 8 and not 8.0. you'll have to parse and handle it accordingly

Infinil
9 Sep, 2023, 05:55

makes sense 👍

Infinil
9 Sep, 2023, 05:56

casting it as num type and then using toDouble() worked :)

Drake
9 Sep, 2023, 15:23

[SOLVED] Appwrite double attribute value is an int

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