skip to Main Content

I want to keep data as Array in firestore by using more than one textformfield in Flutter. How can I send this data as an array? (The number of data is unknown. It could be any number.)

final FirebaseFirestore _firebaseFirestore = FirebaseFirestore.instance;
class _RepairState extends State<Repair> {
String formattedDate = DateFormat('dd-MM-yyyy - kk:mm').format(DateTime.now());
Future createRepairLogs(String title, String email, String desc, String date) async {

await _firebaseFirestore.collection("Repair").doc().set({
  'title': title,
  'email': email,
  'description':desc,
  'dateTime': date,
});
}

title will be an array. I want to have more than one data entry in the title.

Thanks for supporting.

2

Answers


  1. you can convert your array to json which return string like this

    String jsonArray=jsonEncode(["element1", "element2", "element3"]);
    

    then you can obtained the array back by decoding the json

    var list=jsonDecode(jsonArray);
    
    Login or Signup to reply.
  2. change String title to List title

    Future createRepairLogs(String title, String email, String desc, String date) async {
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search