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

import 'package:farm_tpf/utils/const_string.dart'; import 'package:farm_tpf/utils/const_string.dart';


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


try { try {
case DioErrorType.RESPONSE: case DioErrorType.RESPONSE:
int statusCode = dioError.response.statusCode; int statusCode = dioError.response.statusCode;
if (statusCode == 400) { if (statusCode == 400) {
errorDescription = exception_dio_400;
errorDescription = customMessageError ?? exception_dio_400;
} else if (statusCode == 401) { } else if (statusCode == 401) {
errorDescription = exception_dio_401; errorDescription = exception_dio_401;
} else if (statusCode == 403) { } else if (statusCode == 403) {

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

import 'package:farm_tpf/custom_model/password.dart'; 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/data/repository/user_repository.dart';
import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart'; import 'package:farm_tpf/presentation/custom_widgets/widget_loading.dart';
import 'package:farm_tpf/presentation/custom_widgets/widget_toast.dart'; import 'package:farm_tpf/presentation/custom_widgets/widget_toast.dart';
child: WidgetToast(message: "Cập nhật thành công")); child: WidgetToast(message: "Cập nhật thành công"));
Navigator.pop(context); Navigator.pop(context);
}).catchError((onError) { }).catchError((onError) {
var errorMessage = AppException.handleError(onError,
customMessageError: "Sai mật khẩu hiện tại");
_scaffoldKey.currentState.showSnackBar(SnackBar( _scaffoldKey.currentState.showSnackBar(SnackBar(
content: Row( content: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[ children: <Widget>[
Text('Cập nhật không thành công.'),
Flexible(
child: Text(errorMessage),
),
Icon(Icons.error), Icon(Icons.error),
], ],
), ),

Loading…
Cancel
Save