getAppUsageDataInRange method

  1. @override
Future<Map<String, int>> getAppUsageDataInRange(
  1. DateTime startTime,
  2. DateTime endTime
)
override

Implementation

@override
Future<Map<String, int>> getAppUsageDataInRange(
    DateTime startTime, DateTime endTime) async {
  final int startTimeMillis = startTime.millisecondsSinceEpoch;
  final int endTimeMillis = endTime.millisecondsSinceEpoch;

  final List<dynamic> result = await methodChannel.invokeMethod(
    'getAppUsageDataInRange',
    {
      'startTime': startTimeMillis,
      'endTime': endTimeMillis,
    },
  );
  Map<String, int> map = {};
  for (var item in result) {
    map[item['packageName']] = item['totalTimeInForeground'];
  }
  return map;
}