I need to convert a double variable to string to upload it as part of a http post request to the server:
final response = await http.post(Uri.parse(url), body: {
"fecha_inicio": _fechaInicioBBDD,
"fecha_fin": _fechaFinalBBDD,
"latitud": _controllerLatitud.text,
"longitud": _controllerLongitud.text,
"calle": _controllerDireccion.text,
"descripcion": _controllerDescripcion.text,
"tipo_aviso": tipoAviso,
"activar_x_antes": double.parse(_horas.toString())
});
The parameter "activar_x_antes": double.parse(_horas.toString()) is throwing an exception when executing the app:
Unhandled Exception: type 'double' is not a subtype of type 'String' in type cast
The value for _horas = 4.0