feat: introduce BaseDeviceService to standardize interactions with native device features.

This commit is contained in:
Achintha Isuru
2026-02-25 12:29:47 -05:00
parent c3d2a8a910
commit e2f3de3a54
2 changed files with 25 additions and 0 deletions

View File

@@ -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';

View File

@@ -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;
}
}
}