Created
October 4, 2021 17:52
-
-
Save brasizza/5bfd666b926cbe04c04ebab7f90174e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| import 'package:flutter/widgets.dart'; | |
| import 'package:get/get.dart'; | |
| import 'package:hive_tutorial/app/modules/home/controllers/dialog_controller.dart'; | |
| class DialogTodo extends GetView<DialogController> { | |
| DialogTodo({Key? key}) : super(key: key); | |
| final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); | |
| final TextEditingController tileTextController = TextEditingController(); | |
| final TextEditingController descriptionTextController = TextEditingController(); | |
| final TextEditingController tagTextController = TextEditingController(); | |
| @override | |
| Widget build(BuildContext context) { | |
| return Column( | |
| children: [ | |
| const Padding( | |
| padding: EdgeInsets.only(top: 8.0), | |
| child: Text( | |
| "Insert a Task!", | |
| style: TextStyle( | |
| fontSize: 30, | |
| fontWeight: FontWeight.bold, | |
| ), | |
| ), | |
| ), | |
| Padding( | |
| padding: const EdgeInsets.symmetric(horizontal: 30), | |
| child: Form( | |
| key: _formKey, | |
| child: Column( | |
| children: [ | |
| TextFormField( | |
| controller: tileTextController, | |
| enableInteractiveSelection: true, | |
| autovalidateMode: AutovalidateMode.always, | |
| decoration: const InputDecoration( | |
| labelText: 'Title', | |
| ), | |
| validator: (String? value) { | |
| if (value == '') { | |
| return 'A title is required'; | |
| } | |
| return null; | |
| }, | |
| ), | |
| TextFormField( | |
| controller: descriptionTextController, | |
| enableInteractiveSelection: true, | |
| minLines: 3, | |
| maxLines: 5, | |
| decoration: const InputDecoration( | |
| labelText: 'Description', | |
| ), | |
| ), | |
| TextFormField( | |
| controller: tagTextController, | |
| enableInteractiveSelection: true, | |
| minLines: 3, | |
| maxLines: 5, | |
| decoration: const InputDecoration( | |
| labelText: 'Tag your Task with one #hashtag', | |
| ), | |
| ), | |
| Padding( | |
| padding: const EdgeInsets.only(top: 8.0), | |
| child: Obx(() => CheckboxListTile( | |
| title: const Text('Task is done ?'), | |
| value: controller.todoCheck.value, | |
| onChanged: (newVal) { | |
| controller.todoCheck.value = newVal!; | |
| })), | |
| ), | |
| ElevatedButton( | |
| onPressed: () { | |
| if (_formKey.currentState?.validate() == true) { | |
| controller.addTask( | |
| title: tileTextController.text, | |
| description: descriptionTextController.text, | |
| tag: tagTextController.text, | |
| ); | |
| Get.close(0); | |
| } | |
| }, | |
| child: const Text("Save")) | |
| ], | |
| )), | |
| ), | |
| ], | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment