observeQuery method

  1. @override
Future<Stream<String>> observeQuery(
  1. String type, {
  2. DateTime? startDate,
  3. DateTime? endDate,
})
override

Implementation

@override
Future<Stream<String>> observeQuery(
  String type, {
  DateTime? startDate,
  DateTime? endDate,
}) async {
  final channelId =
      await methodChannel.invokeMethod<String>('observeQuery', type);

  if (channelId == null) {
    throw Exception('Failed to create event channel');
  }

  return EventChannel(channelId).receiveBroadcastStream({
    if (startDate != null) 'startDate': startDate.millisecondsSinceEpoch,
    if (endDate != null) 'endDate': endDate.millisecondsSinceEpoch,
  }).map((e) => e as String);
}