This commit is contained in:
agra
2026-01-16 14:11:34 +02:00
commit 2b39c6e17f
155 changed files with 5966 additions and 0 deletions

40
lib/hardware.dart Normal file
View File

@@ -0,0 +1,40 @@
import 'dart:ffi';
import 'dart:io';
import 'hardware_bindings_generated.dart';
const String _libName = 'hardware';
/// The dynamic library in which the symbols for [HardwareBindings] can be found.
final DynamicLibrary _dylib = () {
if (Platform.isMacOS || Platform.isIOS) {
return DynamicLibrary.open('$_libName.framework/$_libName');
}
if (Platform.isAndroid || Platform.isLinux) {
return DynamicLibrary.open('lib$_libName.so');
}
if (Platform.isWindows) {
return DynamicLibrary.open('$_libName.dll');
}
throw UnsupportedError('Unknown platform: ${Platform.operatingSystem}');
}();
/// The bindings to the native functions in [_dylib].
final HardwareBindings _bindings = HardwareBindings(_dylib);
/// Hardware screen information.
class HardwareScreen {
/// Returns the device screen corner radius in logical pixels.
/// Returns null on platforms where the value is not available.
double? get borderRadius {
final result = _bindings.get_screen_border_radius();
if (result.hasValue == 0) return null;
return result.value;
}
}
/// Main Hardware API for accessing device hardware information.
abstract class Hardware {
static final HardwareScreen screen = HardwareScreen();
}