/// Generic interface for a service (eg: logger, analytics…) containing /// one or multiple implementations abstract class SmoothService { SmoothService() : _impls = {}; final Set _impls; Future 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 get impls => _impls; } /// Generic interface for a service implementation abstract class SmoothServiceImpl { Future init(); }