12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import 'package:flutter/material.dart';
- class NewTareaForm extends StatefulWidget {
- const NewTareaForm({super.key});
- @override
- _NewTareaFormState createState() => _NewTareaFormState();
- }
- class _NewTareaFormState extends State<NewTareaForm> {
- final _formKey = GlobalKey<FormState>();
- String _taskName = '';
- void _submitForm() {
- if (_formKey.currentState!.validate()) {
- _formKey.currentState!.save();
-
- Navigator.of(context).pop();
- }
- }
- @override
- Widget build(BuildContext context) {
- return Padding(
- padding: const EdgeInsets.all(16.0),
- child: Form(
- key: _formKey,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Form(
- key: _formKey,
- child: TextFormField(
- decoration: InputDecoration(labelText: 'Ingrese La nueva tarea'),
- validator: (value) {
- if (value == null || value.isEmpty) {
- return 'Porfavor ingrese una tarea';
- }
- return null;
- },
- onSaved: (value) {
- _taskName = value!;
- },
- ),
- ),
- SizedBox(height: 16),
- TextFormField(
- decoration: InputDecoration(labelText: 'Ingrese la prioridad'),
- validator: (value) {
- if (value == null || value.isEmpty) {
- return 'Porfavor ingrese una prioridad';
- }
- return null;
- },
- onSaved: (value) {
- _taskName = value!;
- },
- ),
- SizedBox(height: 16),
- ElevatedButton(
- onPressed: _submitForm,
- child: Text('Nueva Tarea'),
- ),
- ],
- ),
- ),
- );
- }
- }
|