I want to display information that is in the database to the TextFormField
.
How can I do it??
help would be greatly appreciated
Here I leave the code and the image too
iMAGE AND CODE::
I want to display information that is in the database to the TextFormField
.
How can I do it??
help would be greatly appreciated
Here I leave the code and the image too
Flutter/Dart
**************************
final Correo = TextEditingController();
final Contrasena = TextEditingController();
Widget FullName(NombreUsuario){
return new Container(
child: new TextFormField(
controller: Correo,
decoration: const InputDecoration(
icon: Icon(Icons.account_circle),
labelText: 'Nombre de usuario',
),
)
);
}
@override
Widget build(BuildContext context) {
body: Center(
child: new Container(
child: new ListView(
children:[
SizedBox(height: 8,),
FullName(NombreUsuario.text),
SizedBox(height: 28,),
]
),
),
)
);
throw UnimplementedError();
}
}
}
*********************************
List productFromJson(String str) => List<EditarPerfilModel>.from(json.decode(str).map((x) => EditarPerfilModel.fromJson(x)));
class EditarPerfilModel{
String UsuarioContrasenia;
String UsuarioCorreo;
EditarPerfilModel({this.UsuarioPk,this.UsuarioContrasenia,this.UsuarioApodo,this.UsuarioCorreo});
factory EditarPerfilModel.fromJson(Map<String, dynamic> parsedJson){
return EditarPerfilModel(
UsuarioContrasenia: parsedJson['Usuario_Con'],
UsuarioCorreo: parsedJson['Usuario_Correo']
);
}
}
*************************************************
class EditarPerfilServices{
Future EditarPerfil() async{
Map<String, String> headers = {
'Content-Type':'application/json;charset=UTF-8',
'Charset':'utf-8'
};
var Url= Uri.parse("http://....");
final response = await http.get((Url),headers: headers);
print(response.body);
return productFromJson(response.body);
}
}
CodePudding user response:
After you get the String
data from your database, you can simply do :
final Correo = TextEditingController();
Correo.text = stringData;
this will set the stringData to the TextField
or TextFormField
which the Correo controller assigned to.
hope this helps.