cake_wallet/lib/utils/brightness_util.dart
2023-09-22 11:22:32 -04:00

23 lines
No EOL
644 B
Dart

import 'package:cake_wallet/utils/device_info.dart';
import 'package:screen_brightness/screen_brightness.dart';
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:
final double brightness = await ScreenBrightness().current;
// ignore: unawaited_futures
await ScreenBrightness().setScreenBrightness(1.0);
await func();
// ignore: unawaited_futures
await ScreenBrightness().setScreenBrightness(brightness);
}
}