getBlockingState method

  1. @override
Future<BlockingState> getBlockingState()
override

Implementation

@override
Future<BlockingState> getBlockingState() async {
  if (!_isAndroid && !_isIOS) throw _unsupportedPlatform();
  final map = await _invokeMap('getBlockingState');
  return BlockingState(
    isActive: map['active'] == true,
    blockAll: map['blockAll'] == true,
    blockedPackages: List<String>.from(
      map['blockedPackages'] as List? ?? const [],
    ),
    allowedPackages: List<String>.from(
      map['allowedPackages'] as List? ?? const [],
    ),
    blockedUntil: {
      for (final entry in (map['blockedUntil'] as Map? ?? const {}).entries)
        entry.key as String: DateTime.fromMillisecondsSinceEpoch(
          entry.value as int,
        ),
    },
    blockAllUntil: map['blockAllUntil'] == null
        ? null
        : DateTime.fromMillisecondsSinceEpoch(map['blockAllUntil'] as int),
    activeScheduleIds: List<String>.from(
      map['activeScheduleIds'] as List? ?? const [],
    ),
    iosBlockedUntil: map['iosBlockedUntil'] == null
        ? null
        : DateTime.fromMillisecondsSinceEpoch(map['iosBlockedUntil'] as int),
    iosSelectedApplicationCount: map['applicationCount'] as int? ?? 0,
    iosSelectedCategoryCount: map['categoryCount'] as int? ?? 0,
    iosSelectedWebDomainCount: map['webDomainCount'] as int? ?? 0,
  );
}