activityStream method
Stream of activity data
Implementation
@override
Stream<ActivityData> activityStream() =>
_eventChannel.receiveBroadcastStream().map((event) {
try {
final map = Map<String, dynamic>.from(event);
final data = ActivityData.fromMap(map);
if (kDebugMode) {
print('Received event: $data');
}
return data;
} catch (e) {
if (kDebugMode) {
print('Error mapping event: ${e.toString()}');
}
return ActivityData(
timestamp: DateTime.now(), activity: ActivityType.unknown.name);
}
});