import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/form_field_controller.dart'; import 'package:hub/pages/pets_page/pets_page_widget.dart'; import 'package:hub/shared/utils/log_util.dart'; class PetsPageModel extends FlutterFlowModel { late final TabController tabBarController; // Controller para o Upload de Arquivos bool isDataUploading = false; FFUploadedFile uploadedLocalFile = FFUploadedFile(bytes: Uint8List.fromList([])); // Controller para o DropDown String? dropDownValue1; FormFieldController? dropDownValueController1; String? dropDownValue2; FormFieldController? dropDownValueController2; // Controller para o TextField FocusNode? textFieldFocusName; TextEditingController? textControllerName; String? Function(BuildContext, String?)? textControllerNameValidator; String? _textControllerNameValidator(BuildContext context, String? val) { if (val == null || val.isEmpty) { return FFLocalizations.of(context).getVariableText( enText: 'This field is required', ptText: 'Este campo é obrigatório', ); } return null; } FocusNode? textFieldFocusSpecies; TextEditingController? textControllerSpecies; String? Function(BuildContext, String?)? textControllerSpeciesValidator; FocusNode? textFieldFocusRace; TextEditingController? textControllerRace; String? Function(BuildContext, String?)? textControllerRaceValidator; FocusNode? textFieldFocusColor; TextEditingController? textControllerColor; String? Function(BuildContext, String?)? textControllerColorValidator; DateTime? selectedDate; FocusNode? textFieldFocusData; TextEditingController? textControllerData; String? Function(BuildContext, String?)? textControllerDataValidator; String? _textControllerDataValidator(BuildContext context, String? val) { if (val == null || val.isEmpty) { return FFLocalizations.of(context).getVariableText( enText: 'This field is required.', ptText: 'Este campo é obrigatório.', ); } return null; } FocusNode? textFieldFocusObservation; TextEditingController? textControllerObservation; String? Function(BuildContext, String?)? textControllerObservationValidator; @override void initState(BuildContext context) { // Se liga! Esse é o controller do TabBar tabBarController = TabController( vsync: Navigator.of(context), length: 2, ); textFieldFocusName = FocusNode(); textControllerName = TextEditingController(); textControllerNameValidator = (context, value) => _textControllerNameValidator(context, value); textFieldFocusData = FocusNode(); textControllerData = TextEditingController( text: dateTimeFormat( 'dd/MM/yyyy', DateTime.now(), )); textControllerDataValidator = _textControllerDataValidator; dropDownValueController1 = FormFieldController(dropDownValue1 ??= 'Selecione uma opção'); dropDownValueController2 = FormFieldController(dropDownValue2 ??= 'Selecione uma opção'); } @override void dispose() { tabBarController.dispose(); textFieldFocusName?.dispose(); textControllerName?.dispose(); textFieldFocusSpecies?.dispose(); textControllerSpecies?.dispose(); textFieldFocusRace?.dispose(); textControllerRace?.dispose(); textFieldFocusColor?.dispose(); textControllerColor?.dispose(); textFieldFocusData?.dispose(); textControllerData?.dispose(); textFieldFocusObservation?.dispose(); textControllerObservation?.dispose(); dropDownValueController1?.dispose(); dropDownValueController2?.dispose(); } }