Skip to content

Commit

Permalink
handle error widegt
Browse files Browse the repository at this point in the history
  • Loading branch information
mirmoktadir committed Feb 6, 2023
1 parent 92ac01e commit 9f19566
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion animations/error.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion animations/loader.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion animations/nodata.json

This file was deleted.

12 changes: 6 additions & 6 deletions lib/app/components/empty_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class EmptyWidget extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Lottie.asset(
'animations/nodata.json',
height: 100.h,
'animations/error.json',
height: 120.h,
repeat: true,
reverse: true,
fit: BoxFit.cover,
Expand All @@ -35,18 +35,18 @@ class EmptyWidget extends StatelessWidget {
),
SizedBox(height: 40.h),
SizedBox(
height: 52.h,
height: 46.h,
child: ElevatedButton(
onPressed: onPressed,
style: ElevatedButton.styleFrom(
backgroundColor: Colors.grey.shade50,
elevation: 1,
elevation: .5,
shadowColor: theme.hintColor,
),
child: Icon(
Ionicons.refresh,
size: 32,
color: theme.primaryColor,
size: 24,
color: theme.primaryColor.withOpacity(.7),
)),
)
],
Expand Down
14 changes: 6 additions & 8 deletions lib/app/service/api_exceptions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ class DioExceptions implements Exception {
DioExceptions.fromDioError(DioError dioError) {
switch (dioError.type) {
case DioErrorType.cancel:
message = "Request to API server was cancelled";
message = "Request cancelled!";
break;
case DioErrorType.connectTimeout:
message = "Connection timeout with API server";
message = "Connection timeout!";
break;
case DioErrorType.other:
message = "Connection to API server failed due to internet connection";
message = "Connection problem!";
break;
case DioErrorType.receiveTimeout:
message = "Receive timeout in connection with API server";
message = "Receive timeout!";
break;
case DioErrorType.response:
message = _handleError(
dioError.response!.statusCode!.toInt(), dioError.response!.data);
break;
case DioErrorType.sendTimeout:
message = "Send timeout in connection with API server";
message = "Send timeout!";
break;
default:
message = "Something went wrong";
Expand All @@ -38,9 +38,7 @@ class DioExceptions implements Exception {
case 500:
return error['error'] ?? error["message"] ?? "Internal Server Error";
default:
return error['error'] ??
error["message"] ??
'Oops something went wrong';
return error['error'] ?? error["message"] ?? 'Something went wrong';
}
}

Expand Down
3 changes: 1 addition & 2 deletions lib/app/service/base_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class BaseController {
isError.value = true;
var errorText = DioExceptions.fromDioError(error).toString();
Timer(const Duration(milliseconds: 700), () {
CustomSnackBar.showCustomErrorSnackBar(
title: "Error", message: errorText);
CustomSnackBar.showCustomErrorToast(title: "Error", message: errorText);
});

if (kDebugMode) {
Expand Down
4 changes: 2 additions & 2 deletions lib/app/service/helper/dialog_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class DialogHelper {
Center(
child: Container(
height: 80.h,
decoration: const BoxDecoration(
color: Colors.white,
decoration: BoxDecoration(
color: Colors.grey.shade300,
shape: BoxShape.circle,
),
child: OverflowBox(
Expand Down
4 changes: 2 additions & 2 deletions lib/config/theme/light_theme_colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import 'package:flutter/material.dart';

class LightThemeColors {
//dark swatch
//static const Color primaryColor = Color(0xFF40A76A);
static const Color primaryColor = Colors.deepOrangeAccent;
static const Color primaryColor = Color(0xFF40A76A);
//static const Color primaryColor = Colors.deepOrange;
static const Color accentColor = Color(0xFFD9EDE1);

//APPBAR
Expand Down
4 changes: 3 additions & 1 deletion lib/utils/constants.dart
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
class Constants {}
class AppImages {
static String get kAppIcon => 'assets/images/app_icon.png';
}

0 comments on commit 9f19566

Please sign in to comment.