getDatum method Null safety

Future<Datum> getDatum()
override

Subclasses should implement this method to collect a Datum.

Can return null if no data is available. Can return an ErrorDatum if an error occurs.

Implementation

Future<Datum> getDatum() async {
  MarkedMeasure m = (measure as MarkedMeasure);
  int from = (m.lastTime != null)
      ? m.lastTime!.millisecondsSinceEpoch
      : DateTime.now().subtract(m.history).millisecondsSinceEpoch;
  int now = DateTime.now().millisecondsSinceEpoch;
  Iterable<CallLogEntry> entries =
      await CallLog.query(dateFrom: from, dateTo: now);
  return PhoneLogDatum()
    ..phoneLog =
        entries.map((call) => PhoneCall.fromCallLogEntry(call)).toList();
}