import 'package:flutter/material.
dart';
import 'package:http/[Link]' as http;
import '[Link]';
class CreateAccount extends StatefulWidget {
const CreateAccount({[Link]});
@override
State<CreateAccount> createState() => _CreateAccountState();
}
class _CreateAccountState extends State<CreateAccount> {
@override
//email verification
final RegExp emailRegex = RegExp(
r'^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$',
);
//for textcontroller obscure text
bool _obscureText1 = true;
bool _obscureText2 = true;
//text controller declaration
TextEditingController name = TextEditingController();
TextEditingController email = TextEditingController();
TextEditingController pass1 = TextEditingController();
TextEditingController pass2 = TextEditingController();
//for sending data to the database
Future<void> registeracc() async{
final uri = link+ "user_register.php";
Map<String, dynamic> userdata = {
'name' : [Link],
'pass' : [Link],
'email' : [Link]
};
final response = await [Link]([Link](uri), body:userdata,);
print([Link]);
print(userdata);
setState(() {
msg = [Link];
});
}
verification()
{
bool namecheck = [Link];
String checkmail = [Link]();
bool isValidEmail = [Link](checkmail);
bool emptypass1 = [Link];
bool emptypass2 = [Link];
bool passcheck = identical([Link], [Link]);
if (namecheck == false && isValidEmail == true && passcheck == true )
{
if(emptypass1 == false && emptypass2 == false)
{
registeracc();
[Link](context);
setState(() {
msg = "";
});
}
else
{
setState(() {
msg = "Password cannot be empty, please try again ";
});
}
}
else
{
setState(() {
msg = "Something wrong with your credential, please try again ";
});
}
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text('Create an Account',style: TextStyle(fontSize: 20,color:
[Link]),),
),
body: SingleChildScrollView(
child: Padding(
padding: const [Link](top: 30,left: 10,right: 10,bottom: 5),
child: Container(
decoration: BoxDecoration(
border: [Link](
color: Colors.black12,
width: 2.0,
),
borderRadius: [Link](60.0),
color: [Link],
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 5.0,
spreadRadius: 2.0,
offset: Offset(0, 3),
),
],
),
child: Padding(
padding: const [Link](40.0),
child: Column(
children: [
SizedBox(height: 30,),
Container(
child: Column(
children: [
Row(
children: [
Text('Name ',style: TextStyle(fontWeight:
[Link],fontSize: 15,color: [Link]),),
],
),
Container(
decoration: BoxDecoration(
borderRadius: [Link](10.0), // Adjust
the radius as needed
border: [Link](
color: [Link], // Set the border color
width: 2.0, // Set the border width
),
),
child: TextField(
decoration: InputDecoration(
//labelText: 'Name',
border: [Link], // Remove the default
TextField border
contentPadding: [Link](horizontal:
10.0), // Adjust the padding as needed
),
style: TextStyle(color: [Link]),
controller: name
),
),
SizedBox(height: 30,),
Row(
children: [
Text('Email ',style: TextStyle(fontWeight:
[Link],fontSize: 15,color: [Link]),),
],
),
Container(
decoration: BoxDecoration(
borderRadius: [Link](10.0), // Adjust
the radius as needed
border: [Link](
color: [Link], // Set the border color
width: 2.0, // Set the border width
),
),
child: TextField(
decoration: InputDecoration(
//labelText: 'Email',
border: [Link], // Remove the default
TextField border
contentPadding: [Link](horizontal:
10.0), // Adjust the padding as needed
),
style: TextStyle(color: [Link]),
controller: email
),
),
SizedBox(height: 30,),
Row(
children: [
Text('Password ',style: TextStyle(fontWeight:
[Link],fontSize: 15,color: [Link]),),
],
),
Container(
decoration: BoxDecoration(
borderRadius: [Link](10.0), // Adjust
the radius as needed
border: [Link](
color: [Link], // Set the border color
width: 2.0, // Set the border width
),
),
child: TextField(
obscureText: _obscureText1,
decoration: InputDecoration(
//labelText: 'Password',
border: [Link], // Remove the default
TextField border
contentPadding: [Link](left: 10.0,top:
10.0),
//contentPadding: [Link](horizontal:
10.0), // Adjust the padding as needed
suffixIcon: IconButton(
icon: Icon(
_obscureText1 ? [Link] :
Icons.visibility_off,color: [Link],
),
onPressed: () {
setState(() {
_obscureText1 = !_obscureText1;
});
},
),
),
style: TextStyle(color: [Link]),
controller: pass1
),
),
SizedBox(height: 30,),
Row(
children: [
Text('Confirm Password ',style: TextStyle(fontWeight:
[Link],fontSize: 15,color: [Link]),),
],
),
Container(
decoration: BoxDecoration(
borderRadius: [Link](10.0), // Adjust
the radius as needed
border: [Link](
color: [Link], // Set the border color
width: 2.0, // Set the border width
),
),
child: TextField(
obscureText: _obscureText2,
decoration: InputDecoration(
//labelText: 'Password',
border: [Link], // Remove the default
TextField border
contentPadding: [Link](left: 10.0,top:
10.0), // Adjust the padding as needed
suffixIcon: IconButton(
icon: Icon(
_obscureText2 ? [Link] :
Icons.visibility_off,
color: [Link],
),
onPressed: () {
setState(() {
_obscureText2 = !_obscureText2;
});
},
),
),
style: TextStyle(color: [Link]),
controller: pass2
),
),
SizedBox(height: 30,),
Container(
width: 200,
height: 40,
child: ClipRRect(
borderRadius: [Link](100.0), // Set the
border radius
child: Container(
color: [Link],
child: TextButton(
onPressed: () async{
await verification();
[Link] = "";
[Link] = "";
[Link] = "";
[Link] = "";
}, child: Text('Sign Up',style: TextStyle(color:
[Link],fontWeight: [Link])
),
),
),
),
),
SizedBox(height: 15,),
Text(msg, style: TextStyle(color: [Link], fontSize:
15),textAlign: [Link],),
],
),
),
],
),
),
),
),
),
);
}
}