cake_wallet/lib/utils/brightness_util.dart

23 lines
644 B
Dart
Raw Normal View History

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