I have an inconvenience. I have two different classes, one for each form with its respective text box and I want to store the information in the class called CustomerRegistrationModel without the need to create a CustomerRegistrationModel object in each class.
The idea is to save the information of the 2 forms in RegistroClienteModel and then send that to the database
registrousuario11 and registrousuario22 are similar.
code and image::
class RegistroClienteModel{
String contrasena ;
String get Contrasena => contrasena;
String correo ;
String get Correo => correo;
set setContrasena(String usucon) {
contrasena = usucon;
}
set setCorreo(String corre) {
this.correo = corre;
}
String apodo;
String get Apodo => apodo;
set setApodo (String usuapodo) {
this.apodo = usuapodo;
}
String apellido;
String get Apellido => apellido;
set setApellido (String usuapellido) {
this.apellido= usuapellido;
int edad;
int get Edad => edad;
set setApellido (int usuedad) {
this.edad = usuedad;
}
class registrousuario11 extends State<>{
Widget ContrasenaF2(Contrasena){
return new Container(
child: new TextFormField(
// validator: (value)=>value.length < 6?"Contrasena muy corta": null,
controller:Contrasena,
obscureText: true,
decoration: const InputDecoration(
icon: Icon(Icons.lock),
// hintText: 'Ej:123xxx',
labelText: 'Domicilio',
),
)
);
}
Widget CorreoF2(Correo){
return new Container(
child: new TextFormField(
controller: Correo,
// validator: (value)=>!value.contains("@") && value.contains("mail")?"Correo Invalido":null, //para validar si el correo esta correoto
decoration: const InputDecoration(
icon: Icon(Icons.email),
// hintText: 'Ej:xxx@gmail.com',
labelText: 'Apodo',
),
)
);
}
Widget ConfirmarContrasenaF2(ConfirmarContrasena){
return new Container(
child: new TextFormField(
controller: ConfirmarContrasena,
//obscureText: true,
decoration: const InputDecoration(
icon: Icon(Icons.check),
// hintText: 'Validar su contraseƱa',
labelText: 'Edad',
),
)
);
}
@override
Widget build(BuildContext context) {
return new Scaffold(
resizeToAvoidBottomInset: false,
appBar: new AppBar(
title: new Text("Formulario2"),
centerTitle: true,
automaticallyImplyLeading: false,
),
body: Center(
child: new Container(
//padding: EdgeInsets.all(20.0),
padding: EdgeInsets.only(
left: 10,right: 10,// Para que el teclado no este sobre el texto
bottom: MediaQuery.of(context).viewInsets.bottom),
// padding: const EdgeInsets.all(20.0), // Margen a todos los componentes(textfield,botones etc...)
child: new ListView(
children:[
SizedBox(height: 8,),
SizedBox(height: 28,),
CorreoF2(Correo),
SizedBox(height: 28,),
ContrasenaF2(Contrasena),
SizedBox(height: 28,),
ConfirmarContrasenaF2(ConfirmarContrasena),
]
),
),
)
);
throw UnimplementedError();
}
}
}
class registrousuario22 extends State<>{}

