I am saving texts to a MySQL remote database.
I am using a TextFormField to capture the text
TextFormField(
controller: _asunto_controller,
decoration: InputDecoration(
),
),
And then I am using the following function to upload the form data to the database
Future webCall() async {
// API URL
var url = Constantes().URLProyecto + Constantes().APICarpeta + 'guardar_publicacion.php';
// Store all data with Param Name.
var data = {
'enviado_por': miId,
'texto': textoPost,
'fecha': fechaPost,
'especialidad': especialidadPost,
'asunto': asuntoPost,
'codigo': codigo_pub,
'nombre': miNombre,
'apellidos': misApellidos,
'icono_esp': iconoPost,
'nombre_esp': nombreEspecialidadPost,
};
// Starting Web Call with data.
var response = await http.post(url, body: json.encode(data));
String respuesta = response.body;
String correcto = "OK";
if (respuesta.compareTo(correcto) == 0) {
Toast.show(
"PostCreated".tr().toString(), context,
duration: Toast.LENGTH_LONG,
gravity: Toast.CENTER,
backgroundColor: AppColors.azulCapenergy,
textColor: Colors.white);
Navigator.push(context, MaterialPageRoute(builder: (context) => Foro()));
}
else {
Toast.show(
"Error", context,
duration: Toast.LENGTH_LONG,
gravity: Toast.CENTER,
backgroundColor: AppColors.azulCapenergy,
textColor: Colors.white);
}
}
My issue is sometimes, the app user is adding emojis to the TextFormField, and the emojis are sent to the database as ???? not as emoji or the needed emoji code or whatever code is needed.
Some emojis are saved as emoji directly to the database like the second one here:
????ggg☺️ ????
But on the shown text, the ???? string was an emoji when creating the text.
I would like to know if there is a way to handle the text inserted so that every inserted emoji will be recognized as emoji and not as ????.