feat: introduce BaseDeviceService to standardize interactions with native device features.
This commit is contained in:
@@ -12,6 +12,9 @@ export 'src/core/services/api_services/base_api_service.dart';
|
||||
export 'src/core/services/api_services/base_core_service.dart';
|
||||
export 'src/core/services/api_services/file_visibility.dart';
|
||||
|
||||
// Device
|
||||
export 'src/core/services/device/base_device_service.dart';
|
||||
|
||||
// Users & Membership
|
||||
export 'src/entities/users/user.dart';
|
||||
export 'src/entities/users/staff.dart';
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/// Abstract base class for device-related services.
|
||||
///
|
||||
/// Device services handle native hardware/platform interactions
|
||||
/// like Camera, Gallery, Location, or Biometrics.
|
||||
abstract class BaseDeviceService {
|
||||
const BaseDeviceService();
|
||||
|
||||
/// Standardized wrapper to execute device actions.
|
||||
///
|
||||
/// This can be used for common handling like logging device interactions
|
||||
/// or catching native platform exceptions.
|
||||
Future<T> action<T>(Future<T> Function() execution) async {
|
||||
try {
|
||||
return await execution();
|
||||
} catch (e) {
|
||||
// Re-throw or handle based on project preference.
|
||||
// For device services, we might want to throw specific
|
||||
// DeviceExceptions later.
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user