WIP
This commit is contained in:
parent
624f00cc1f
commit
68fc17890d
|
@ -13,6 +13,8 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
late final TabController tabBarController;
|
late final TabController tabBarController;
|
||||||
VoidCallback? onUpdatePet;
|
VoidCallback? onUpdatePet;
|
||||||
VoidCallback? onRegisterPet;
|
VoidCallback? onRegisterPet;
|
||||||
|
final GlobalKey<FormState> registerFormKey = GlobalKey<FormState>();
|
||||||
|
final GlobalKey<FormState> updateFormKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
ApiCallResponse? petsResponse;
|
ApiCallResponse? petsResponse;
|
||||||
int? petId;
|
int? petId;
|
||||||
|
@ -234,8 +236,22 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
)
|
)
|
||||||
.then((response) {
|
.then((response) {
|
||||||
if (response.jsonBody['error'] == true) {
|
if (response.jsonBody['error'] == true) {
|
||||||
DialogUtil.error(buildContext!,
|
String errorMessage = '';
|
||||||
jsonDecode(response.jsonBody['error_msg'])[0]['message']);
|
try {
|
||||||
|
errorMessage = jsonDecode(response.jsonBody['error_msg'])[0]
|
||||||
|
['message']
|
||||||
|
.toString();
|
||||||
|
} catch (e) {
|
||||||
|
errorMessage = 'An error occurred.';
|
||||||
|
if (response.jsonBody['error_msg'] ==
|
||||||
|
"Limite de Cadastro de Pet Atingido.") {
|
||||||
|
errorMessage = FFLocalizations.of(buildContext!).getVariableText(
|
||||||
|
enText: 'Pet registration limit reached',
|
||||||
|
ptText: 'Limite de cadastro de pets atingido',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DialogUtil.error(buildContext!, errorMessage);
|
||||||
} else if (response.jsonBody['error'] == false) {
|
} else if (response.jsonBody['error'] == false) {
|
||||||
DialogUtil.success(
|
DialogUtil.success(
|
||||||
buildContext!,
|
buildContext!,
|
||||||
|
@ -265,6 +281,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
void clearFields() {
|
void clearFields() {
|
||||||
uploadedLocalFile = null;
|
uploadedLocalFile = null;
|
||||||
|
|
||||||
|
textControllerName?.clear();
|
||||||
textControllerName?.clear();
|
textControllerName?.clear();
|
||||||
textControllerSpecies?.clear();
|
textControllerSpecies?.clear();
|
||||||
textControllerRace?.clear();
|
textControllerRace?.clear();
|
||||||
|
|
|
@ -51,7 +51,6 @@ class PetsPageWidget extends StatefulWidget {
|
||||||
class _PetsPageWidgetState extends State<PetsPageWidget>
|
class _PetsPageWidgetState extends State<PetsPageWidget>
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
late PetsPageModel _model;
|
late PetsPageModel _model;
|
||||||
final _formKey = GlobalKey<FormState>();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -61,12 +60,13 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
||||||
_model.onUpdatePet = () {
|
_model.onUpdatePet = () {
|
||||||
safeSetState(() {
|
safeSetState(() {
|
||||||
_model.clearFields();
|
_model.clearFields();
|
||||||
// _formKey.currentState?.reset();
|
_model.updateFormKey.currentState?.reset();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
_model.onRegisterPet = () {
|
_model.onRegisterPet = () {
|
||||||
safeSetState(() {
|
safeSetState(() {
|
||||||
_model.clearFields();
|
_model.clearFields();
|
||||||
|
_model.registerFormKey.currentState?.reset();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Form(
|
Form(
|
||||||
key: _formKey,
|
key: _model.registerFormKey,
|
||||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
@ -665,7 +665,7 @@ class _PetsPageWidgetState extends State<PetsPageWidget>
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Form(
|
Form(
|
||||||
key: _formKey,
|
key: _model.updateFormKey,
|
||||||
autovalidateMode: AutovalidateMode.onUserInteraction,
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
|
Loading…
Reference in New Issue