2025-05-11 10:48:10 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
2023-02-11 12:58:47 +00:00
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
|
|
|
class CaffeineService {
|
2025-05-11 10:48:10 +00:00
|
|
|
@visibleForTesting
|
|
|
|
static const caffeineMethodChannel = MethodChannel("com.vodemn.lightmeter.CaffeinePlatformChannel.MethodChannel");
|
2023-02-11 12:58:47 +00:00
|
|
|
|
|
|
|
const CaffeineService();
|
|
|
|
|
|
|
|
Future<bool> isKeepScreenOn() async {
|
2025-05-11 10:48:10 +00:00
|
|
|
return caffeineMethodChannel.invokeMethod<bool>("isKeepScreenOn").then((value) => value!);
|
2023-02-11 12:58:47 +00:00
|
|
|
}
|
|
|
|
|
2023-06-23 08:35:33 +00:00
|
|
|
Future<bool> keepScreenOn(bool keep) async {
|
2025-05-11 10:48:10 +00:00
|
|
|
return caffeineMethodChannel.invokeMethod<bool>("setKeepScreenOn", keep).then((value) => value!);
|
2023-02-11 12:58:47 +00:00
|
|
|
}
|
|
|
|
}
|