getWallpaperBrightness method

Future<int> getWallpaperBrightness ({int skipPixel: 1 })

This gets the brightness of current Wallpaper to determine theme (light or dark). The function returns a brightness level between 0 and 255, where 0 = totally black and 255 = totally bright.

skipPixel parameter refers to number of pixels to skip while calculating Wallpaper's brightness. skipPixel defaults to 1 (every pixel is counted) and can't be less than 1.

Note:

  • This method needs the READ_EXTERNAL_STORAGE permission on Android Oreo & above.

Implementation

static Future<int> getWallpaperBrightness({int skipPixel = 1}) async {
  assert(skipPixel > 0, 'skipPixel should have a value greater than 0');
  debugPrint(
      "[LauncherHelper] External Storage Access permission might be needed for Android Oreo & above.");
  int data = await _channel
      .invokeMethod('getWallpaperBrightness', {'skipPixel': skipPixel});
  return data;
}