mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 20:39:51 +00:00
Add Brightness Util to check for platform before increasing brightness (#1096)
This commit is contained in:
parent
b6de1be6c4
commit
95ea825728
4 changed files with 42 additions and 50 deletions
23
lib/utils/brightness_util.dart
Normal file
23
lib/utils/brightness_util.dart
Normal file
|
@ -0,0 +1,23 @@
|
|||
import 'package:cake_wallet/utils/device_info.dart';
|
||||
import 'package:device_display_brightness/device_display_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 brightness = await DeviceDisplayBrightness.getBrightness();
|
||||
|
||||
// ignore: unawaited_futures
|
||||
DeviceDisplayBrightness.setBrightness(1.0);
|
||||
|
||||
await func();
|
||||
|
||||
// ignore: unawaited_futures
|
||||
DeviceDisplayBrightness.setBrightness(brightness);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue