This is Textformfield. It receives the value and then displays the information through it. TextEditContoller
This is page 1
Widget lngTextFormField(String label, String keyword, String text) {
TextEditingController lngtextController = TextEditingController(text: text);
lngtextController.selection = TextSelection.collapsed(offset: lngtextController.text.length);
return TextFormField(
controller: lngtextController,
onChanged: (value) {
saveAd(value, keyword);
},
decoration: InputDecoration(
labelText: label,
labelStyle: TextStyle(
fontFamily: 'supermarket',
fontSize: 16,
),
isDense: true,
),
);
}
This is a page 2 This is a save button that will return lat,lng to page 1.
void saveAddress() {
var lat = centerMap.latitude;
var lng = centerMap.longitude;
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => EditAddressPage(
index: widget.index,
lat: lat.toString(),
lng: lng.toString(),
),
),
);
print("Saving address: Latitude: $lat, Longitude: $lng");
}
what can i do I want to send the second page lat,lng values back to page 1 instead of the existing values. I tried this, sometimes the value is sent but the original value is empty before the new value is sent. Maybe need to type something in TextFormfield before being able to save