Browse Source

fix Bug #7345

master
daivph 5 years ago
parent
commit
33d25250c3
2 changed files with 8 additions and 3 deletions
  1. +2
    -2
      lib/data/api/app_exception.dart
  2. +6
    -1
      lib/presentation/screens/profile/sc_change_password.dart

+ 2
- 2
lib/data/api/app_exception.dart View File

@@ -4,7 +4,7 @@ import 'package:dio/dio.dart';
import 'package:farm_tpf/utils/const_string.dart';

class AppException {
static String handleError(dynamic error) {
static String handleError(dynamic error, {String customMessageError}) {
String errorDescription = "";

try {
@@ -25,7 +25,7 @@ class AppException {
case DioErrorType.RESPONSE:
int statusCode = dioError.response.statusCode;
if (statusCode == 400) {
errorDescription = exception_dio_400;
errorDescription = customMessageError ?? exception_dio_400;
} else if (statusCode == 401) {
errorDescription = exception_dio_401;
} else if (statusCode == 403) {

+ 6
- 1
lib/presentation/screens/profile/sc_change_password.dart View File

@@ -1,4 +1,5 @@
import 'package:farm_tpf/custom_model/password.dart';
import 'package:farm_tpf/data/api/app_exception.dart';
import 'package:farm_tpf/data/repository/user_repository.dart';
import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart';
import 'package:farm_tpf/presentation/custom_widgets/widget_toast.dart';
@@ -41,11 +42,15 @@ class _ChangePasswordScreenState extends State<ChangePasswordScreen> {
child: WidgetToast(message: "Cập nhật thành công"));
Navigator.pop(context);
}).catchError((onError) {
var errorMessage = AppException.handleError(onError,
customMessageError: "Sai mật khẩu hiện tại");
_scaffoldKey.currentState.showSnackBar(SnackBar(
content: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text('Cập nhật không thành công.'),
Flexible(
child: Text(errorMessage),
),
Icon(Icons.error),
],
),

Loading…
Cancel
Save