import 'package:get_it/get_it.dart'; import '../controller/settings.dart'; import '../../services/notification.dart'; import 'companies.dart'; import 'event_organisations.dart'; import 'interfaces.dart'; class PushNotificationTopicModel with Name, IsSubscribable { final String id; final String name; get subscribed => SettingsController.subscribed(this); subscribe(bool subscribe) { if(subscribe) { SettingsController.subscribeTopic(this); ExternalNotificationConnector.subscribe(this); } else { SettingsController.unsubscribeTopic(this); ExternalNotificationConnector.unsubscribe(this); } } const PushNotificationTopicModel(this.id, this.name); factory PushNotificationTopicModel.fromJson(Map json) { return PushNotificationTopicModel( json['id'] as String, json['name'] as String ); } static List values = GetIt.I>()..addAll(EventOrganisationModel.values)..addAll(CompanyModel.values)..sort((a, b) => a.name.compareTo(b.name)); bool operator ==(Object other) => other is PushNotificationTopicModel && runtimeType == other.runtimeType && id == other.id; int get hashCode => id.hashCode; }