2023-09-22 14:53:30 +00:00
|
|
|
import 'package:cake_wallet/utils/device_info.dart';
|
2023-09-22 15:22:32 +00:00
|
|
|
import 'package:screen_brightness/screen_brightness.dart';
|
2023-09-22 14:53:30 +00:00
|
|
|
|
|
|
|
class BrightnessUtil {
|
|
|
|
static Future<void> changeBrightnessForFunction(Future<void> Function() func) async {
|
|
|
|
// if not mobile, just navigate
|
|
|
|
if (!DeviceInfo.instance.isMobile) {
|
|
|
|
func();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the current brightness:
|
2023-09-22 15:22:32 +00:00
|
|
|
final double brightness = await ScreenBrightness().current;
|
2023-09-22 14:53:30 +00:00
|
|
|
|
|
|
|
// ignore: unawaited_futures
|
2023-09-22 15:22:32 +00:00
|
|
|
await ScreenBrightness().setScreenBrightness(1.0);
|
2023-09-22 14:53:30 +00:00
|
|
|
|
|
|
|
await func();
|
|
|
|
|
|
|
|
// ignore: unawaited_futures
|
2023-09-22 15:22:32 +00:00
|
|
|
await ScreenBrightness().setScreenBrightness(brightness);
|
2023-09-22 14:53:30 +00:00
|
|
|
}
|
|
|
|
}
|