resolveForPlatform method

Permission resolveForPlatform({
  1. required bool isAndroid,
})

Resolves the correct native Permission for the given platform context.

On Android, CkPermission.photos and CkPermission.storage map to Permission.mediaLibrary because Android uses the unified media permission model. On all other platforms (iOS, Web, macOS, Linux, Windows) the standard toNative() mapping is used.

This method is the single source of truth for the Android-specific substitution. Both CkPermissionHelper and CkPermissionHandler call this instead of duplicating the platform-branch logic.

The isAndroid parameter is injectable for testing — pass Platform.isAndroid in production code and true/false in tests to simulate any of the 6 supported platforms without a real device.

Implementation

Permission resolveForPlatform({required bool isAndroid}) {
  if ((this == CkPermission.photos || this == CkPermission.storage) &&
      isAndroid) {
    return Permission.mediaLibrary;
  }
  return toNative();
}