mirror of
https://github.com/openfoodfacts/smooth-app.git
synced 2025-08-06 18:25:11 +08:00

* 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
29 lines
606 B
Dart
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();
|
|
}
|