[SOLVED] What would be Dart data type for a String Array attribute in a database collection ?
- 0
- Databases
- Functions
I tried List<String> but function errors out
"Type '_GrowableList<dynamic> is not a subtype of 'List<String>'
Anyone can share a quick sample of a dart cloud function to read from and write to an string array attribute in a collection.
you can do value.cast<String>(); but it might be better to be more defensive and check if value were null and default to an empty list.
Sorry but I would need more then that. I currently getDocument and then
List<String> x = received document.data['array_attribute']
So what do I change ?
Apologies for dumbing it down
Like so
List<dynamic> dList = ['First string', 'And another'];
List<String> stringList = dynamiclist.cast<String>();
So in your example you can do
List<String> data = document.data['array_attribute'].cast<String>();
@punti_z did you get your question resolved or still needed help? checking to see if we should close or not 🙂
[Closed] What would be Dart data type for a String Array attribute in a database collection ?
Done
[SOLVED] What would be Dart data type for a String Array attribute in a database collection ?
Recommended threads
- How Can I Create landing page in appwrit...
I created function called invoice URL https://app.getrestt.com/v1/functions/invoice/executions?id=test-76f948fe83c43422561fe096c0674a1bd3ff0702cdfcf2444293ab31...
- Couldnt not do appwrite push tables
Not sure why i am not able to create my tables
- DeploymentStatus enum value `canceled` m...
Hey, Sorry if it has been reported already, I found an issue using the Dart SDK where the `canceled` enum value is missing from `DeploymentStatus`. This causes...