refactor : rename files and update routes for poultry actions
feat : poultry kill registration and poultry OrderList ** Made With Nima **
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
extension XNumExtension on num? {
|
||||
String get separatedByComma {
|
||||
String get separatedByCommaFa {
|
||||
final formatter = NumberFormat('#,###', 'fa_IR');
|
||||
return this == null ? '':formatter.format(this);
|
||||
}
|
||||
|
||||
|
||||
String get separatedByComma {
|
||||
final formatter = NumberFormat('#,###', 'en_US');
|
||||
return this == null ? '':formatter.format(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core.dart';
|
||||
|
||||
/// Handles global API requests management with CancelToken.
|
||||
class ApiHandler {
|
||||
// Global CancelToken for all requests.
|
||||
@@ -24,8 +25,6 @@ class ApiHandler {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef AppAsyncCallback<T> = Future<T> Function();
|
||||
typedef ErrorCallback = Function(dynamic error, StackTrace? stackTrace);
|
||||
typedef VoidCallback = void Function();
|
||||
@@ -56,12 +55,11 @@ Future<T?> gSafeCall<T>({
|
||||
final result = await call();
|
||||
|
||||
if (showSuccess) {
|
||||
(onShowSuccessMessage ?? _defaultShowSuccessMessage)('عملیات با موفقیت انجام شد');
|
||||
(onShowSuccessMessage ?? defaultShowSuccessMessage)('عملیات با موفقیت انجام شد');
|
||||
}
|
||||
|
||||
onSuccess?.call(result);
|
||||
return result;
|
||||
|
||||
} catch (error, stackTrace) {
|
||||
retryCount++;
|
||||
|
||||
@@ -75,7 +73,6 @@ Future<T?> gSafeCall<T>({
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (retryCount > maxRetries || !_isRetryableError(error)) {
|
||||
if (showError) {
|
||||
final message = _getErrorMessage(error);
|
||||
@@ -85,7 +82,6 @@ Future<T?> gSafeCall<T>({
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (retryCount <= maxRetries) {
|
||||
await Future.delayed(retryDelay);
|
||||
}
|
||||
@@ -108,8 +104,7 @@ bool _isRetryableError(dynamic error) {
|
||||
return error.type == DioExceptionType.connectionTimeout ||
|
||||
error.type == DioExceptionType.receiveTimeout ||
|
||||
error.type == DioExceptionType.sendTimeout ||
|
||||
(error.response?.statusCode != null &&
|
||||
error.response!.statusCode! >= 500);
|
||||
(error.response?.statusCode != null && error.response!.statusCode! >= 500);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -146,10 +141,7 @@ String _getErrorMessage(dynamic error) {
|
||||
|
||||
void _defaultShowLoading() {
|
||||
// نمایش loading
|
||||
Get.dialog(
|
||||
Center(child: CircularProgressIndicator()),
|
||||
barrierDismissible: false,
|
||||
);
|
||||
Get.dialog(Center(child: CircularProgressIndicator()), barrierDismissible: false);
|
||||
}
|
||||
|
||||
void _defaultHideLoading() {
|
||||
@@ -159,12 +151,22 @@ void _defaultHideLoading() {
|
||||
}
|
||||
}
|
||||
|
||||
void _defaultShowSuccessMessage(String message) {
|
||||
void defaultShowSuccessMessage(
|
||||
String message, {
|
||||
int durationInSeconds = 2,
|
||||
VoidCallback? onDismissed,
|
||||
}) {
|
||||
Get.snackbar(
|
||||
'موفقیت',
|
||||
message,
|
||||
duration: Duration(seconds: durationInSeconds),
|
||||
snackPosition: SnackPosition.TOP,
|
||||
backgroundColor: Colors.green,
|
||||
snackbarStatus: (status) {
|
||||
if (status == SnackbarStatus.CLOSED) {
|
||||
onDismissed?.call();
|
||||
}
|
||||
},
|
||||
colorText: Colors.white,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user