fix: validação do campo e tratamento de exceção
This commit is contained in:
parent
2bc3db5c44
commit
1ca638dc77
|
@ -230,12 +230,25 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dropDownValue1 == null || dropDownValue1!.isEmpty || dropDownValue1 == '') {
|
if (dropDownValueController1!.value == 'Selecione uma opção' ||
|
||||||
|
dropDownValueController1!.value == '' ||
|
||||||
|
dropDownValueController1!.value == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (dropDownValue2 == null || dropDownValue2!.isEmpty || dropDownValue2 == '') {
|
if (dropDownValueController2!.value == 'Selecione uma opção' ||
|
||||||
|
dropDownValueController2!.value == '' ||
|
||||||
|
dropDownValueController2!.value == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dropDownValue1 == 'Selecione uma opção' || dropDownValue1 == null || dropDownValue1 == '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dropDownValue2 == 'Selecione uma opção' || dropDownValue2 == null || dropDownValue2 == '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +271,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.jsonBody['error'] == false) {
|
if (response.jsonBody['error'] == false) {
|
||||||
DialogUtil.success(
|
await DialogUtil.success(
|
||||||
buildContext!,
|
buildContext!,
|
||||||
FFLocalizations.of(buildContext!).getVariableText(
|
FFLocalizations.of(buildContext!).getVariableText(
|
||||||
enText: 'Pet successfully updated',
|
enText: 'Pet successfully updated',
|
||||||
|
@ -279,7 +292,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
ptText: 'Falha ao atualizar o pet',
|
ptText: 'Falha ao atualizar o pet',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
DialogUtil.error(buildContext!, errorMessage);
|
await DialogUtil.error(buildContext!, errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,7 +312,7 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.jsonBody['error'] == false) {
|
if (response.jsonBody['error'] == false) {
|
||||||
DialogUtil.success(
|
await DialogUtil.success(
|
||||||
buildContext!,
|
buildContext!,
|
||||||
FFLocalizations.of(buildContext!).getVariableText(
|
FFLocalizations.of(buildContext!).getVariableText(
|
||||||
enText: 'Pet successfully registered',
|
enText: 'Pet successfully registered',
|
||||||
|
@ -311,15 +324,16 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
String errorMessage;
|
String errorMessage;
|
||||||
try {
|
try {
|
||||||
errorMessage = jsonDecode(response.jsonBody['error_msg'])[0]['message'].toString();
|
errorMessage = jsonDecode(response.jsonBody['error_msg'])[0]['message'].toString();
|
||||||
|
await DialogUtil.error(buildContext!, errorMessage);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (response.jsonBody['error_msg'] == "Limite de Cadastro de Pet Atingido.") {
|
if (response.jsonBody['error_msg'] == "Limite de Cadastro de Pet Atingido.") {
|
||||||
errorMessage = FFLocalizations.of(buildContext!).getVariableText(
|
errorMessage = FFLocalizations.of(buildContext!).getVariableText(
|
||||||
enText: 'Pet registration limit reached',
|
enText: 'Pet registration limit reached',
|
||||||
ptText: 'Limite de cadastro de pets atingido',
|
ptText: 'Limite de cadastro de pets atingido',
|
||||||
);
|
);
|
||||||
DialogUtil.error(buildContext!, errorMessage);
|
await DialogUtil.error(buildContext!, errorMessage);
|
||||||
} else {
|
} else {
|
||||||
DialogUtil.errorDefault(buildContext!);
|
await DialogUtil.errorDefault(buildContext!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,10 +373,8 @@ class PetsPageModel extends FlutterFlowModel<PetsPageWidget> {
|
||||||
// dropDownValue1 = '';
|
// dropDownValue1 = '';
|
||||||
// dropDownValue2 = '';
|
// dropDownValue2 = '';
|
||||||
|
|
||||||
// dropDownValueController1 =
|
// dropDownValueController1 = FormFieldController<String>('Selecione uma opção');
|
||||||
// FormFieldController<String>('Selecione uma opção');
|
// dropDownValueController2 = FormFieldController<String>('Selecione uma opção');
|
||||||
// dropDownValueController2 =
|
|
||||||
// FormFieldController<String>('Selecione uma opção');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildPetDetails({
|
Widget buildPetDetails({
|
||||||
|
|
Loading…
Reference in New Issue