You are on page 1of 11

UNIVERSIDAD DIGITAL DEL ESTADO DE HIDALGO

INGENIERIA DE SOFTWARE

ESTUDIANTE: ISRAEL MARTÍNEZ RAMÍREZ

MATRÍCULA: 2030494

ASESOR (A): JORGE ALBERTO HERNÁNDEZ TAPIA

UNIDAD DE APRENDIZAJE:

Programación en dispositivos móviles

ACTIVIDAD DE APRENDIZAJE:
AI7. Creación de un Login Page | Buzón.

FECHA DE ENTREGA
23 DE OCTUBRE 2022
1. Código.

2. import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {


@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: HomePage(),
theme: ThemeData.dark(),
darkTheme: ThemeData.dark(),
);
}
}

class HomePage extends StatefulWidget {


@override
_HomePageState createState() =>
_HomePageState();
}

class _HomePageState extends State<HomePage> {


final GlobalKey<FormState> _formKey =
GlobalKey<FormState>();
final _scaffoldKey = GlobalKey<ScaffoldState>();

// bool validate = false;

@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
appBar: AppBar(
title: Text("Formulario"),
centerTitle: true,
),
body: ListView(
children: [
Column(
children: [
Center(
child: Container(
height: 80,
width: 80,
decoration: new BoxDecoration(
shape: BoxShape.circle,
image: new
DecorationImage(
image: new
NetworkImage("https://i.pinimg.com/564x/ac/95/1a/a
c951a6b30df48534984de9fdece79e6.jpg"),
fit: BoxFit.fill)),
),
),
Divider(
color: Colors.green,
indent: 2.0,
endIndent: 2.0,
),
Padding(
padding: EdgeInsets.only(left:
30.0, right: 30.0),
),
Form(
key: _formKey,
//autovalidateMode: validator,
child: Column(
children: [
TextFormField(
decoration:
InputDecoration(labelText: "Nombre"),
keyboardType:
TextInputType.text,
onFieldSubmitted: (value)
{
//Validator
},
validator: (value) {
if (value == null ||
!RegExp(r'(^[a-zA-Z
]*$)').hasMatch(value!)) {
return 'Nombre
incorrecto';
}
return null;
},
),
Padding(
padding:
EdgeInsets.only(top: 2, bottom: 2),
),
TextFormField(
decoration:
InputDecoration(labelText: "Apellido Paterno"),
keyboardType:
TextInputType.text,
onFieldSubmitted: (value)
{
//Validator
},
validator: (value) {
if (value == null ||
!RegExp(r'(^[a-zA-Z
]*$)').hasMatch(value!)) {
return 'Apellido
Paterno incorrecto';
}
return null;
},
),
Padding(
padding:
EdgeInsets.only(top: 2, bottom: 2),
),
TextFormField(
decoration:
InputDecoration(labelText: "Apellido Materno"),
keyboardType:
TextInputType.text,
onFieldSubmitted: (value)
{
//Validator
},
validator: (value) {
if (value == null ||
!RegExp(r'(^[a-zA-Z
]*$)').hasMatch(value!)) {
return 'Apellido
Materno incorrecto';
}
return null;
},
),
Padding(
padding:
EdgeInsets.only(top: 2, bottom: 2),
),
TextFormField(
decoration:
InputDecoration(labelText: "E-mail"),
keyboardType:
TextInputType.emailAddress,
onFieldSubmitted: (value)
{
//Validator
},
validator: (value) {
if (value == null ||
!RegExp(r"^[a-zA-Z0-
9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-
9]+\.[a-zA-Z]+")

.hasMatch(value!)) {
return 'Ingrese un
correo valido!';
}
return null;
},
),
Padding(
padding:
EdgeInsets.only(top: 2, bottom: 2),
),
TextFormField(
decoration:
InputDecoration(labelText: "Teléfono Celular"),
keyboardType:
TextInputType.emailAddress,
onFieldSubmitted: (value)
{
//Validator
},
validator: (value) {
if (value == null ||

!RegExp(r"^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-
9]*$")

.hasMatch(value!)) {
return 'Ingrese solo
números!';
}
return null;
},
),
Padding(
padding:
EdgeInsets.only(top: 2, bottom: 2),
),
TextFormField(
decoration:
InputDecoration(labelText: "Contraseña"),
keyboardType:
TextInputType.text,
onFieldSubmitted: (value)
{
//Validator
},
),
Padding(
padding:
EdgeInsets.only(top: 2, bottom: 2),
),
TextFormField(
decoration:
InputDecoration(labelText:
"Ingrese Contraseña Valida"),
keyboardType:
TextInputType.text,
onFieldSubmitted: (value)
{
//Validator
},
),
],
),
),
Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: [
MaterialButton(
child: Text("Login"),
color: Colors.blueAccent,
onPressed: () {
if
(_formKey.currentState!.validate()) {

ScaffoldMessenger.of(context).showSnackBar(
const
SnackBar(content: Text('Processing Data')),
);
}
},
),
],
),
],
)
],
));
}

//Métodos para validar


_NonEmptyTextValidator(String value) =>
value.isEmpty ? "Data canot Empty" : null;

_MailValidator(String value) {
return value.contains("@") == false ? "Not a
valid Email" : null;
}

_showSnackBar(BuildContext context, String


message) {
final snackBar = SnackBar(content:
Text(message));

ScaffoldMessenger.of(context).showSnackBar(snackBa
r);
}
}

2. Validaciones.

You might also like