How to store Geopoint to Firebase with Flutter

529

Geopoint there is GeoPoint object inside Firestore plugin

'locationCoords':GeoPoint(_textEditingController5.GeoPoint.latitude,_textEditingController5.GeoPoint.longitude);
Share:
529
user16034511
Author by

user16034511

Updated on December 30, 2022

Comments

  • user16034511
    user16034511 over 1 year

    I have set up a Textformfield where users can fill in their shop & Geopoint coordinates.

    They then press the submit button and it updates on our Firestore collection.

    The problem I am having is how to save it as Geopoint's and not a string.

    SizedBox(child: ElevatedButton(
      onPressed: () async { 
        await collectionReference.add({ 
          'shopName':  _textEditingController.text,
          'address': _textEditingController2.text, 
          'description': _textEditingController3.text, 
          'thumbNail': _textEditingController4.text,
          'locationCoords':_textEditingController5.GeoPoint
        },);
      },
      chil:Text('Add Data'),
    ))
    
  • user16034511
    user16034511 almost 3 years
    This worked Would I need to change my Text Controller as well? final _textEditingController5 = TextEditingController(); How do I allow it to accept coordinates?
  • Fatima ayaa
    Fatima ayaa almost 3 years
    according to your needs, the main thing is to recover longitude and attitude