Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
primera_practica
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yenisleydi Benitez Martinez
primera_practica
Commits
c4971193
Commit
c4971193
authored
Aug 02, 2024
by
yenisleydi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modificaciones
parent
2f23dbd8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
9 deletions
+6
-9
formulario_categoria.dart
lib/src/pages/formulario_categoria.dart
+6
-9
No files found.
lib/src/pages/formulario_categoria.dart
View file @
c4971193
...
@@ -19,11 +19,11 @@ class _FormularioCategoriaState extends State<FormularioCategoria> {
...
@@ -19,11 +19,11 @@ class _FormularioCategoriaState extends State<FormularioCategoria> {
}
}
void
_guardarCategoria
()
{
void
_guardarCategoria
()
{
final
nombre
=
_nombreController
.
text
;
final
nombre
=
_nombreController
.
text
;
// se obtiene el calor de nombre y clave
final
clave
=
_claveController
.
text
;
final
clave
=
_claveController
.
text
;
if
(
nombre
.
isEmpty
||
clave
.
isEmpty
)
{
if
(
nombre
.
isEmpty
||
clave
.
isEmpty
)
{
// Mostrar un mensaje de error si algún campo está vacío
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
const
SnackBar
(
content:
Text
(
'Por favor, complete todos los campos'
)),
const
SnackBar
(
content:
Text
(
'Por favor, complete todos los campos'
)),
);
);
...
@@ -38,11 +38,8 @@ class _FormularioCategoriaState extends State<FormularioCategoria> {
...
@@ -38,11 +38,8 @@ class _FormularioCategoriaState extends State<FormularioCategoria> {
"nombre"
:
nombre
,
"nombre"
:
nombre
,
};
};
print
(
categoria
);
// Imprime el mensaje en consola
print
(
categoria
);
// Aquí puedes agregar lógica adicional para guardar los datos en una base de datos o enviar a una API
// Volver a la pantalla anterior
Navigator
.
pop
(
context
);
Navigator
.
pop
(
context
);
}
}
...
@@ -53,7 +50,7 @@ class _FormularioCategoriaState extends State<FormularioCategoria> {
...
@@ -53,7 +50,7 @@ class _FormularioCategoriaState extends State<FormularioCategoria> {
title:
const
Text
(
'Agregar Categoría'
),
title:
const
Text
(
'Agregar Categoría'
),
),
),
body:
Padding
(
body:
Padding
(
padding:
const
EdgeInsets
.
all
(
1
80
.0
),
padding:
const
EdgeInsets
.
all
(
1
6
.0
),
child:
Column
(
child:
Column
(
children:
<
Widget
>[
children:
<
Widget
>[
TextField
(
TextField
(
...
@@ -61,13 +58,13 @@ class _FormularioCategoriaState extends State<FormularioCategoria> {
...
@@ -61,13 +58,13 @@ class _FormularioCategoriaState extends State<FormularioCategoria> {
decoration:
const
InputDecoration
(
labelText:
'Clave'
),
decoration:
const
InputDecoration
(
labelText:
'Clave'
),
keyboardType:
TextInputType
.
text
,
keyboardType:
TextInputType
.
text
,
),
),
const
SizedBox
(
height:
40
),
const
SizedBox
(
height:
16
),
TextField
(
TextField
(
controller:
_nombreController
,
controller:
_nombreController
,
decoration:
const
InputDecoration
(
labelText:
'Nombre'
),
decoration:
const
InputDecoration
(
labelText:
'Nombre'
),
keyboardType:
TextInputType
.
text
,
keyboardType:
TextInputType
.
text
,
),
),
const
SizedBox
(
height:
30
),
const
SizedBox
(
height:
16
),
ElevatedButton
(
ElevatedButton
(
onPressed:
_guardarCategoria
,
onPressed:
_guardarCategoria
,
child:
const
Text
(
'GUARDAR'
),
child:
const
Text
(
'GUARDAR'
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment