I have this 3 screen registration forms, the first one requests for Email, Password and Confirm password then the second screen requests for other users information including names, Phone number and address while the last one is the OTP confirmation page
Now I want to call all entered data into the first screen onto the second screen where I will confirm if the otp is correct before saving the data to database.
This is the registration model:
class Registration {
int id;
String firstNmae;
String lastName;
String email;
String password;
int phone;
String address;
Registration({
this.id,
this.firstNmae,
this.lastName,
this.email,
this.password,
this.phone,
this.address,
});
}
And this is my controller:
import 'package:get/get_state_manager/get_state_manager.dart';
import 'package:signuptest/models/RegistrationModel.dart';
class RegistrationController extends GetxController {
var registration = [];
}
On the first Signup Screen:
class SignUpForm extends StatefulWidget {
@override
_SignUpFormState createState() => _SignUpFormState();
}
class _SignUpFormState extends State<SignUpForm> {
final RegistrationController registrationController =
Get.find<RegistrationController>();
TextEditingController emailTextEditingController = TextEditingController();
TextEditingController passwordTextEditingController = TextEditingController();
TextEditingController cPasswordTextEditingController =
TextEditingController();
...
//First Screen Onpressed Function:
onpress: () {
if (_formKey.currentState.validate()) {
registrationController.registration.add(Registration(
email: emailTextEditingController.text,
password: passwordTextEditingController.text,
));
Navigator.pushNamed(context, CompleteProfileScreen.routeName);
}
Now on the complete Profile screen "Second Screen" i tried to display the data "Email Address" filled on the first screen to be sure it actually saving the user input but when typing the the name "email or emailTextEditingController" My VScode doesn't suggest the name for me and when I type it directly it shows red line under it
I tried passing the "email" as the value for the Text() widget:
class CompleteProfileForm extends StatefulWidget {
@override
_CompleteProfileFormState createState() => _CompleteProfileFormState();
}
class _CompleteProfileFormState extends State<CompleteProfileForm> {
final RegistrationController registrationController =
Get.put(RegistrationController());
...
@override
Widget build(BuildContext context) {
return Form(
child: Column(
children: [
Text(registrationController.registration.email), //I get a red line under the email which says..
...
The error I get is:
The getter 'email' isn't defined for the type 'List'. Try importing the library that defines 'email', correcting the name to the name of an existing getter, or defining a getter or field named 'email'
I guess I am calling it wrongly or something.
I have seen a lot of questions about same issues but most of them have no confirmed answer and secondly I don't want to pass the data as argument