A Flutter widget to show an icon collection to pick. This widget extend TextField and has a similar behavior as TextFormField
11
stars
8
forks
source link
delay 3 seconds or a little more in open the _showIconPickerDialog #4
Open
brokercl opened 2 years ago
class CustomForm extends StatelessWidget { final _formKey = GlobalKey();
CustomForm({Key? key}) : super(key: key);
@override Widget build(BuildContext context) { return Form( key: _formKey, child: Column( children:[
IconPicker(
controller: expenseController.categoryTextEditingController,
icon: const Icon(Icons.start),
onChanged: (jsonIcon) {
}
),
TextFormField(
decoration: const InputDecoration(
hintText: 'category ?',
),
validator: (validateText) => validateInputText(validateText, 'category has to be at least 3 characters long..')
),
Container(
padding: const EdgeInsets.only(left: 50.0, top: 40.0),
child: Row(
children: [
IconButton(onPressed: () => Get.back(), icon: const Icon(Icons.cancel)),
const SizedBox(width: 60,),
IconButton(
icon: const Icon(Icons.save),
onPressed: () {
// It returns true if the form is valid, otherwise returns false
if (_formKey.currentState!.validate()) { // If the form is valid, display a Snackbar. Get.snackbar( 'texto', 'validado ok..', snackPosition: SnackPosition.BOTTOM ); } }, ), ], ), ) ], ), ); } }
validateInputText(String? validateText, String errorMessage) { if (validateText!.isEmpty || validateText.length < 3) {
return errorMessage; }
return null; }`