fix reset form
This commit is contained in:
parent
fb137ef4f3
commit
4f35d67b02
|
@ -12,6 +12,7 @@ import '/custom_code/actions/index.dart' as actions;
|
|||
class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||
late final TabController tabBarController;
|
||||
VoidCallback? onUpdatePet;
|
||||
VoidCallback? onRegisterPet;
|
||||
|
||||
ApiCallResponse? petsResponse;
|
||||
int? petId;
|
||||
|
@ -209,6 +210,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
ptText: 'Pet atualizado com sucesso',
|
||||
));
|
||||
clearFields();
|
||||
onUpdatePet?.call();
|
||||
switchTab(1);
|
||||
}).catchError((error) {
|
||||
log(error.toString());
|
||||
|
@ -246,7 +248,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
ptText: 'Pet cadastrado com sucesso',
|
||||
));
|
||||
clearFields();
|
||||
onUpdatePet?.call();
|
||||
onRegisterPet?.call();
|
||||
}).catchError((error) {
|
||||
DialogUtil.errorDefault(buildContext!);
|
||||
});
|
||||
|
@ -255,7 +257,6 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
|||
void switchTab(int index) {
|
||||
tabBarController.animateTo(index);
|
||||
if (index == 1) handleEditingChanged(false);
|
||||
onUpdatePet?.call();
|
||||
}
|
||||
|
||||
void handleUploadComplete(FFUploadedFile uploadedFile) {
|
||||
|
|
|
@ -60,6 +60,11 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
|||
_model.tabBarController = TabController(length: 2, vsync: this);
|
||||
_model.onUpdatePet = () {
|
||||
setState(() {});
|
||||
Form.of(context).reset();
|
||||
};
|
||||
_model.onRegisterPet = () {
|
||||
setState(() {});
|
||||
Form.of(context).reset();
|
||||
};
|
||||
|
||||
widget.pet != null ? _model.isEditing = true : _model.isEditing = false;
|
||||
|
|
Loading…
Reference in New Issue