Files
smooth-app/packages/smooth_app/lib/services/smooth_service.dart
Edouard Marquez 97d36bc71c feat: Logs service (+ email attachment) (#2303)
* Logs service (+ email attachment)

* Fix flutter format warning

* Reformat code

* Remove fimber_io dependency to have our own implementations instead

* Add close:true to email dialog

* Add SENDTO query to AndroidManifest

* Remove useless comment
2022-06-23 15:14:28 +02:00

29 lines
606 B
Dart

/// Generic interface for a service (eg: logger, analytics…) containing
/// one or multiple implementations
abstract class SmoothService<T extends SmoothServiceImpl> {
SmoothService() : _impls = <T>{};
final Set<T> _impls;
Future<bool> attach(T impl) async {
if (!_impls.contains(impl)) {
_impls.add(impl);
await impl.init();
return true;
}
return false;
}
bool detach(T impl) {
return _impls.remove(impl);
}
Set<T> get impls => _impls;
}
/// Generic interface for a service implementation
abstract class SmoothServiceImpl {
Future<void> init();
}