const constructure
This commit is contained in:
@@ -36,7 +36,7 @@ class AnalyticRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(AnalyticFailure.unexpectedError());
|
||||
return DC.error(const AnalyticFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final dashboard = DashboardAnalyticDto.fromJson(
|
||||
@@ -65,7 +65,7 @@ class AnalyticRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(AnalyticFailure.unexpectedError());
|
||||
return DC.error(const AnalyticFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final sales = SalesAnalyticDto.fromJson(
|
||||
@@ -94,7 +94,7 @@ class AnalyticRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(AnalyticFailure.unexpectedError());
|
||||
return DC.error(const AnalyticFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final products = ProductAnalyticDto.fromJson(
|
||||
@@ -123,7 +123,7 @@ class AnalyticRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(AnalyticFailure.unexpectedError());
|
||||
return DC.error(const AnalyticFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final paymentMethods = PaymentMethodAnalyticDto.fromJson(
|
||||
@@ -152,7 +152,7 @@ class AnalyticRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(AnalyticFailure.unexpectedError());
|
||||
return DC.error(const AnalyticFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final profitLoss = ProfitLossAnalyticDto.fromJson(
|
||||
@@ -181,7 +181,7 @@ class AnalyticRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(AnalyticFailure.unexpectedError());
|
||||
return DC.error(const AnalyticFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final categories = CategoryAnalyticDto.fromJson(
|
||||
@@ -211,7 +211,7 @@ class AnalyticRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(AnalyticFailure.unexpectedError());
|
||||
return DC.error(const AnalyticFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final inventory = InventoryAnalyticDto.fromJson(
|
||||
|
||||
@@ -30,7 +30,7 @@ class AuthRemoteDataProvider {
|
||||
|
||||
if (response.data['code'] == 401) {
|
||||
return DC.error(
|
||||
AuthFailure.serverError(
|
||||
const AuthFailure.serverError(
|
||||
ApiFailure.unauthorized('Incorrect email or password'),
|
||||
),
|
||||
);
|
||||
@@ -52,7 +52,7 @@ class AuthRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(AuthFailure.unexpectedError());
|
||||
return DC.error(const AuthFailure.unexpectedError());
|
||||
}
|
||||
|
||||
return DC.data(unit);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// ignore_for_file: prefer_const_constructors
|
||||
|
||||
part of '../auth_dtos.dart';
|
||||
|
||||
@freezed
|
||||
|
||||
@@ -17,7 +17,9 @@ class CategoryLocalDataProvider {
|
||||
CategoryLocalDataProvider(this._databaseHelper);
|
||||
|
||||
final Map<String, List<CategoryDto>> _queryCache = {};
|
||||
final Duration _cacheExpiry = Duration(minutes: AppConstant.cacheExpire);
|
||||
final Duration _cacheExpiry = const Duration(
|
||||
minutes: AppConstant.cacheExpire,
|
||||
);
|
||||
final Map<String, DateTime> _cacheTimestamps = {};
|
||||
|
||||
Future<DC<CategoryFailure, void>> saveCategoriesBatch(
|
||||
@@ -203,7 +205,7 @@ class CategoryLocalDataProvider {
|
||||
|
||||
if (maps.isEmpty) {
|
||||
log('❌ Category not found: $id', name: _logName);
|
||||
return DC.error(CategoryFailure.empty());
|
||||
return DC.error(const CategoryFailure.empty());
|
||||
}
|
||||
|
||||
final category = CategoryDto.fromMap(maps.first);
|
||||
|
||||
@@ -29,7 +29,7 @@ class CategoryRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['data'] == null) {
|
||||
return DC.error(CategoryFailure.empty());
|
||||
return DC.error(const CategoryFailure.empty());
|
||||
}
|
||||
|
||||
final categories = ListCategoryDto.fromJson(
|
||||
|
||||
@@ -29,7 +29,7 @@ class CustomerRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(CustomerFailure.unexpectedError());
|
||||
return DC.error(const CustomerFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final customers = ListCustomerDto.fromJson(
|
||||
|
||||
@@ -46,7 +46,7 @@ class OrderRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(OrderFailure.unexpectedError());
|
||||
return DC.error(const OrderFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final orders = ListOrderDto.fromJson(
|
||||
@@ -68,7 +68,7 @@ class OrderRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(OrderFailure.unexpectedError());
|
||||
return DC.error(const OrderFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final order = OrderDto.fromJson(
|
||||
@@ -93,7 +93,7 @@ class OrderRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(OrderFailure.unexpectedError());
|
||||
return DC.error(const OrderFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final order = OrderDto.fromJson(
|
||||
@@ -119,7 +119,7 @@ class OrderRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(OrderFailure.unexpectedError());
|
||||
return DC.error(const OrderFailure.unexpectedError());
|
||||
} else {
|
||||
final order = OrderDto.fromJson(
|
||||
response.data['data'] as Map<String, dynamic>,
|
||||
@@ -161,7 +161,7 @@ class OrderRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(OrderFailure.unexpectedError());
|
||||
return DC.error(const OrderFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final payment = PaymentDto.fromJson(
|
||||
@@ -190,7 +190,7 @@ class OrderRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(OrderFailure.unexpectedError());
|
||||
return DC.error(const OrderFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final order = OrderDto.fromJson(
|
||||
@@ -227,7 +227,7 @@ class OrderRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(OrderFailure.unexpectedError());
|
||||
return DC.error(const OrderFailure.unexpectedError());
|
||||
}
|
||||
|
||||
return DC.data(unit);
|
||||
@@ -249,7 +249,7 @@ class OrderRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(OrderFailure.unexpectedError());
|
||||
return DC.error(const OrderFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final payment = PaymentDto.fromJson(
|
||||
@@ -276,7 +276,7 @@ class OrderRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(OrderFailure.unexpectedError());
|
||||
return DC.error(const OrderFailure.unexpectedError());
|
||||
}
|
||||
|
||||
return DC.data(unit);
|
||||
|
||||
@@ -29,7 +29,7 @@ class OutletRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['data'] == null) {
|
||||
return DC.error(OutletFailure.empty());
|
||||
return DC.error(const OutletFailure.empty());
|
||||
}
|
||||
|
||||
final outlets = (response.data['data']['outlets'] as List)
|
||||
@@ -51,7 +51,7 @@ class OutletRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['data'] == null) {
|
||||
return DC.error(OutletFailure.empty());
|
||||
return DC.error(const OutletFailure.empty());
|
||||
}
|
||||
|
||||
final outlet = OutletDto.fromJson(
|
||||
|
||||
@@ -29,7 +29,7 @@ class PaymentMethodRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(PaymentMethodFailure.unexpectedError());
|
||||
return DC.error(const PaymentMethodFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final paymentMethods = ListPaymentMethodDto.fromJson(
|
||||
|
||||
@@ -26,7 +26,7 @@ class PrinterLocalDataProvider {
|
||||
|
||||
if (printerExist.hasData) {
|
||||
return DC.error(
|
||||
PrinterFailure.dynamicErrorMessage('Printer Telah Terdaftar'),
|
||||
const PrinterFailure.dynamicErrorMessage('Printer Telah Terdaftar'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class PrinterLocalDataProvider {
|
||||
log('Error creating printer', name: _logName, error: e);
|
||||
|
||||
return DC.error(
|
||||
PrinterFailure.dynamicErrorMessage('Error creating printer'),
|
||||
const PrinterFailure.dynamicErrorMessage('Error creating printer'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ class PrinterLocalDataProvider {
|
||||
|
||||
if (updatedRows == 0) {
|
||||
return DC.error(
|
||||
PrinterFailure.dynamicErrorMessage('Printer not found'),
|
||||
const PrinterFailure.dynamicErrorMessage('Printer not found'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class PrinterLocalDataProvider {
|
||||
log('Error updating printer', name: _logName, error: e);
|
||||
|
||||
return DC.error(
|
||||
PrinterFailure.dynamicErrorMessage('Error updating printer'),
|
||||
const PrinterFailure.dynamicErrorMessage('Error updating printer'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ class PrinterLocalDataProvider {
|
||||
|
||||
if (deletedRows == 0) {
|
||||
return DC.error(
|
||||
PrinterFailure.dynamicErrorMessage('Printer not found'),
|
||||
const PrinterFailure.dynamicErrorMessage('Printer not found'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ class PrinterLocalDataProvider {
|
||||
log('Error deleting printer', name: _logName, error: e);
|
||||
|
||||
return DC.error(
|
||||
PrinterFailure.dynamicErrorMessage('Error deleting printer'),
|
||||
const PrinterFailure.dynamicErrorMessage('Error deleting printer'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -123,7 +123,7 @@ class PrinterLocalDataProvider {
|
||||
|
||||
if (result.isEmpty) {
|
||||
log('Printer with code $code not found');
|
||||
return DC.error(PrinterFailure.empty());
|
||||
return DC.error(const PrinterFailure.empty());
|
||||
}
|
||||
|
||||
final printer = PrinterDto.fromJson(result.first);
|
||||
@@ -133,7 +133,7 @@ class PrinterLocalDataProvider {
|
||||
log('findPrinterByCode', name: _logName, error: e);
|
||||
|
||||
return DC.error(
|
||||
PrinterFailure.dynamicErrorMessage('Error getting printer'),
|
||||
const PrinterFailure.dynamicErrorMessage('Error getting printer'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class PrinterRepository implements IPrinterRepository {
|
||||
);
|
||||
log("Error connecting to Bluetooth printer", name: _logName, error: e);
|
||||
return left(
|
||||
PrinterFailure.dynamicErrorMessage(
|
||||
const PrinterFailure.dynamicErrorMessage(
|
||||
'Error connecting to Bluetooth printer',
|
||||
),
|
||||
);
|
||||
@@ -102,7 +102,7 @@ class PrinterRepository implements IPrinterRepository {
|
||||
} catch (e) {
|
||||
log("Error disconnecting Bluetooth printer", error: e, name: _logName);
|
||||
return left(
|
||||
PrinterFailure.dynamicErrorMessage(
|
||||
const PrinterFailure.dynamicErrorMessage(
|
||||
'Error disconnecting Bluetooth printer',
|
||||
),
|
||||
);
|
||||
@@ -121,7 +121,7 @@ class PrinterRepository implements IPrinterRepository {
|
||||
} catch (e) {
|
||||
log("Error getting paired Bluetooth devices", name: _logName, error: e);
|
||||
return left(
|
||||
PrinterFailure.dynamicErrorMessage(
|
||||
const PrinterFailure.dynamicErrorMessage(
|
||||
'Error getting paired Bluetooth devices',
|
||||
),
|
||||
);
|
||||
@@ -137,7 +137,9 @@ class PrinterRepository implements IPrinterRepository {
|
||||
} catch (e) {
|
||||
log("Error checking Bluetooth status", name: _logName, error: e);
|
||||
return left(
|
||||
PrinterFailure.dynamicErrorMessage('Error checking Bluetooth status'),
|
||||
const PrinterFailure.dynamicErrorMessage(
|
||||
'Error checking Bluetooth status',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -254,7 +256,7 @@ class PrinterRepository implements IPrinterRepository {
|
||||
],
|
||||
);
|
||||
return left(
|
||||
PrinterFailure.dynamicErrorMessage(
|
||||
const PrinterFailure.dynamicErrorMessage(
|
||||
'Printer cannot connect to bluetooth, Please connect in printer setting!',
|
||||
),
|
||||
);
|
||||
@@ -306,7 +308,7 @@ class PrinterRepository implements IPrinterRepository {
|
||||
],
|
||||
);
|
||||
return left(
|
||||
PrinterFailure.dynamicErrorMessage('Error printing struct'),
|
||||
const PrinterFailure.dynamicErrorMessage('Error printing struct'),
|
||||
);
|
||||
}
|
||||
});
|
||||
@@ -339,7 +341,7 @@ class PrinterRepository implements IPrinterRepository {
|
||||
information: ['Printer: ${printer.name}', 'IP: ${printer.address}'],
|
||||
);
|
||||
return left(
|
||||
PrinterFailure.dynamicErrorMessage('Error printing struct'),
|
||||
const PrinterFailure.dynamicErrorMessage('Error printing struct'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@ class ProductLocalDataProvider {
|
||||
final _logName = 'ProductLocalDataProvider';
|
||||
|
||||
final Map<String, List<ProductDto>> _queryCache = {};
|
||||
final Duration _cacheExpiry = Duration(minutes: AppConstant.cacheExpire);
|
||||
final Duration _cacheExpiry = const Duration(
|
||||
minutes: AppConstant.cacheExpire,
|
||||
);
|
||||
final Map<String, DateTime> _cacheTimestamps = {};
|
||||
|
||||
ProductLocalDataProvider(this._databaseHelper);
|
||||
@@ -281,7 +283,7 @@ class ProductLocalDataProvider {
|
||||
|
||||
if (maps.isEmpty) {
|
||||
log('❌ Product not found: $id', name: _logName);
|
||||
return DC.error(ProductFailure.empty());
|
||||
return DC.error(const ProductFailure.empty());
|
||||
}
|
||||
|
||||
final variants = await _getProductVariants(db, id);
|
||||
|
||||
@@ -41,7 +41,7 @@ class ProductRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['data'] == null) {
|
||||
return DC.error(ProductFailure.empty());
|
||||
return DC.error(const ProductFailure.empty());
|
||||
}
|
||||
|
||||
final categories = ListProductDto.fromJson(
|
||||
|
||||
@@ -38,7 +38,7 @@ class TableRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['data'] == null) {
|
||||
return DC.error(TableFailure.empty());
|
||||
return DC.error(const TableFailure.empty());
|
||||
}
|
||||
|
||||
final tables = ListTableDto.fromJson(
|
||||
@@ -71,7 +71,7 @@ class TableRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(TableFailure.unexpectedError());
|
||||
return DC.error(const TableFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final table = TableDto.fromJson(
|
||||
@@ -99,7 +99,7 @@ class TableRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(TableFailure.unexpectedError());
|
||||
return DC.error(const TableFailure.unexpectedError());
|
||||
}
|
||||
|
||||
final table = TableDto.fromJson(
|
||||
@@ -124,7 +124,7 @@ class TableRemoteDataProvider {
|
||||
);
|
||||
|
||||
if (response.data['success'] == false) {
|
||||
return DC.error(TableFailure.unexpectedError());
|
||||
return DC.error(const TableFailure.unexpectedError());
|
||||
}
|
||||
|
||||
return DC.data(unit);
|
||||
|
||||
Reference in New Issue
Block a user