Designing the Sign-Up Page for the Flutter Ecommerce App

Nishant Patel
peanutsquarellp
Published in
3 min readAug 18, 2023

In this section, we will shift our focus to designing the sign-up page for our Flutter ecommerce app. The sign-up page allows new users to create an account and join the platform. We will design an intuitive and user-friendly sign-up page that includes input fields for personal information, email, password, and a sign-up button. Additionally, we may include optional fields for additional details or preferences. Following the principles of responsive design, we will ensure that the page layout adapts seamlessly to various screen sizes. By creating an appealing and streamlined sign-up page, we aim to provide a smooth and efficient onboarding experience for new users. Let’s proceed with designing the sign-up page to facilitate user registration and engagement in our app.

import 'package:clickmart/view/authentication/sign_in.dart';
import 'package:flutter/material.dart';
import 'package:flutter_signin_button/flutter_signin_button.dart';

class SignUp extends StatefulWidget {
const SignUp({super.key});

@override
State<SignUp> createState() => _SignUpState();
}

class _SignUpState extends State<SignUp> {
// Form Key
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();

// TextForm Controller
TextEditingController emailController = TextEditingController();
TextEditingController passwordController = TextEditingController();

// Form Validation
bool _validateAndSave() {
final form = _formKey.currentState;
if (form!.validate()) {
form.save();
return true;
}
return false;
}

void _validateAndSubmit() {
if (_validateAndSave()) {
// TODO: Perform sign-up logic here
}
}

@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () {
return Future.value(false);
},
child: Scaffold(
appBar: AppBar(
automaticallyImplyLeading: false,
title: const Text('Sign Up'),
),
body: Container(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
TextFormField(
controller: emailController,
decoration: const InputDecoration(labelText: 'Email'),
validator: (value) {
if (value!.isEmpty) {
return 'Please enter your email';
}
return null;
},
onSaved: (value) => emailController.text = value!,
),
const SizedBox(height: 16.0),
TextFormField(
controller: passwordController,
decoration: const InputDecoration(labelText: 'Password'),
obscureText: true,
validator: (value) {
if (value!.isEmpty) {
return 'Please enter your password';
}
return null;
},
onSaved: (value) => passwordController.text = value!,
),
const SizedBox(height: 16.0),
ElevatedButton(
onPressed: _validateAndSubmit,
child: const Text('Sign Up'),
),
const SizedBox(height: 16.0),
Center(
child: GestureDetector(
onTap: _navigateToSignIn,
child: RichText(
text: const TextSpan(
text: 'Have an account? ',
style: TextStyle(color: Colors.black),
children: <TextSpan>[
TextSpan(
text: 'Sign In',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.blue,
),
),
],
),
),
),
),
const SizedBox(height: 16.0),
const Center(
child: Text('Or'),
),
const SizedBox(height: 16.0),
SignInButton(
Buttons.Google,
onPressed: () {
// TODO: Implement Google sign-in logic here
},
),
],
),
),
),
),
);
}

// Goto SignUp Page
void _navigateToSignIn() {
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (context) => const SignIn()),
);
}
}

OUTPUT:

Conclusion

.

.

Click Here to Read Continue.

(Previous)________(Next)

--

--