REGISTER PAGE




                                          Register page & input values  


* First Create Register Page Ui design.set the validator values.


*First create appBar I given the title name (Login page) .


Sample code:

appBar: AppBar(
title: const Center(child: Text('Register Page')),
),


*Next step is create body context I used to Widgets (Column,padding,TextFromField ,RaisedButton)


Sample Code:

* This is TextFromField Widgets.

1.InputDecration

2.PrefixIcon.

3.OutlineInputBorder

4.LabelText

5.hintText


*Create one class name is (User) I created given the String values for Five values.next

Creat one list Store the values.

my List name is ( 'List<User?> userList = <User?>[];  ' )


*Create one Method in Calling object methods declear the values and add the list.



class User {
String? user;
String? fname;
String? lname;
String? password;
String? conpassword;
}

class Regestpage extends StatelessWidget {
Regestpage({Key? key}) : super(key: key);

GlobalKey<FormState> fromkeys = new GlobalKey();

TextEditingController _username = new TextEditingController();
TextEditingController _fname = new TextEditingController();
TextEditingController _lname = new TextEditingController();
TextEditingController _password = new TextEditingController();
TextEditingController _conpassword = new TextEditingController();

bool secure = true;

static List<User?> userList = <User?>[];

test() {
User obj = new User();
obj.user = _username.text;
obj.lname = _fname.text;
obj.lname = _lname.text;
obj.password = _password.text;
obj.conpassword = _conpassword.text;

userList.add(obj);
}



body: SingleChildScrollView(
child: Form(
key: fromkeys,
child: Column(
children: [
Padding(
padding: EdgeInsets.all(15),
child: TextFormField(
controller: _username,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: "Enter the user name",
hintText: "Name"),
validator: (value) {
if (value!.isEmpty) {
return 'Enter the user name';
} else {
return null;
}
},
),
),
Padding(
padding: EdgeInsets.all(15),
child: TextFormField(
controller: _fname,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: "Enter the Fast name",
hintText: "Name"),
validator: (value) {
if (value!.isEmpty) {
return 'Enter the fast name';
} else {
return null;
}
},
),
),
Padding(
padding: EdgeInsets.all(15),
child: TextFormField(
controller: _lname,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: "Enter the Last name",
hintText: "Name"),
validator: (value) {
if (value!.isEmpty) {
return 'Enter the last name';
} else {
return null;
}
},
),
),
Padding(
padding: EdgeInsets.all(15),
child: TextFormField(
controller: _password,
obscureText: true,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: "Enter the New Password",
hintText: "PASSWORD"),
validator: (value) {
if (value!.isEmpty) {
return 'Enter the new password ';
} else if (value.length < 8) {
return 'Enter the 8 digit character';
} else {
return null;
}
},
),
),
Padding(
padding: EdgeInsets.all(15),
child: TextFormField(
controller: _conpassword,
obscureText: true,
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: "Confirm Password",
hintText: 'PASSWORD'),
validator: (value) {
if (value!.isEmpty) {
return 'Enter the confirm password name';
} else if (_password.text != _conpassword.text) {
return 'the password is not match';
} else if (value.length < 8) {
return 'Enter the 8 digit character';
} else {
return null;
}
},
),
),
RaisedButton(
textColor: Colors.white,
color: Colors.blue,
child: Text('Submit'),
onPressed: () {
if (fromkeys.currentState!.validate()) {
test();
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => loginpage()),
);
} else {
print("Invalid");
}
},
),
],
),
),
),



This is UI design:




Validator Page:










* I Register in the page Fille the values in Store the list.

Name and User name ,Password, Conform Password.And

Click the Submit Button Push the next page  going to Login page.




*Then Login page Same user name and Same password given the login page.

I given the user name and password based to login page is working.
 
user name and passwor wrong Validator message show.

correct name and password give login page successfuly.

login() {
if (Regestpage.userList.length > 0) {
for (User? log in Regestpage.userList) {
if ((log?.user == _names.text) && (log?.password == _passwords.text)) {
return true;
} else {
return false;
}
}
} else {
return false;
}
}


body: Form(
key: formkey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: EdgeInsets.all(15),
child: TextFormField(
controller: _names,
decoration: InputDecoration(
prefixIcon: Icon(Icons.mail),
border: OutlineInputBorder(),
labelText: "Enter the User name",
hintText: "User Name"),
validator: (value) {
if (value!.isEmpty) {
return 'Enter the user name';
}
for (User? log in Regestpage.userList) {
if (log?.user != _names.text) {
return 'wrong username';
} else {
return null;
}
}
},
),
),
Padding(
padding: EdgeInsets.all(15),
child: TextFormField(
controller: _passwords,
obscureText: secure,
decoration: InputDecoration(
prefixIcon: Icon(Icons.lock),
suffixIcon: IconButton(
onPressed: () {
setState(() {
secure = !secure;
});
},
icon: Icon(
secure ? Icons.visibility_off : Icons.visibility),
),
border: OutlineInputBorder(),
labelText: "Enter the Password",
hintText: "Password"),
validator: (value) {
if (value!.isEmpty) {
return 'Enter the password';
} else if (value.length < 8) {
return 'password 8 digit only';
}
for (User? log in Regestpage.userList) {
if (log?.password != _passwords.text) {
return 'wrong password';
} else {
return null;
}
}
}),
),
RaisedButton(
textColor: Colors.white,
color: Colors.blue,
child: Text('Login'),
onPressed: () {
if (formkey.currentState!.validate()) {
bool isCorrect = login();
if (isCorrect) {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => Welcomepage(),
));
}
} else {
print("Invalid");
}
},
),
],
),
),







body: SingleChildScrollView(
child: Column(
children: [
SizedBox(
height: 20,
),
Container(
height: 30,
width: 180,
child: Text(
'Login Successfuly',
style: TextStyle(fontSize: 20, color: Colors.green),
),
),


floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => AccountsCreatepage(),
),
);
},
),










Post a Comment

Previous Post Next Post

نموذج الاتصال