native_system_kit 1.0.0
native_system_kit: ^1.0.0 copied to clipboard
A production-grade Flutter plugin for advanced native system features (Background Services, Alarms, Hardware Control, System Info).
Native System Kit #
A powerful, production-grade Flutter plugin for accessing advanced native system features on Android and iOS. Designed for enterprise apps, kiosks, and system utilities.
Features #
- Background Services: Run persistent background tasks with foreground service support.
- Exact Alarms: Schedule precise alarms and notifications.
- Power Management: Control WakeLocks and check Battery Saver status.
- Device Hardware:
- Flashlight: Toggle the device torch.
- Brightness: Get/Set System Brightness (with auto-permission handling on Android).
- Volume: Get/Set Media Volume.
- Real-time Synchronization: Listen to system volume and brightness changes.
- System Info:
- Check Total/Free Disk Space.
- Check Total/Free RAM.
- Root/Jailbreak Detection.
- Process Lifecycle: Monitor app lifecycle events (Trim Memory, Low Memory).
- System Events: Listen to screen on/off, power connected/disconnected, and more.
Installation #
Add this to your package's pubspec.yaml file:
dependencies:
native_system_kit: ^0.0.1
Platform Setup #
Android #
Add the necessary permissions to your android/app/src/main/AndroidManifest.xml depending on the features you use:
<manifest ...>
<!-- Background Service -->
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<!-- Power Manager -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<!-- Alarms (Android 12+) -->
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
<!-- Brightness Control -->
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<application ...>
<!-- Register the Service -->
<service android:name="com.example.native_system_kit.NativeSystemKitService"
android:foregroundServiceType="dataSync"
android:exported="false" />
<!-- Register Alarm Receiver -->
<receiver android:name="com.example.native_system_kit.AlarmReceiver"
android:exported="false"/>
</application>
</manifest>
iOS #
Add the following keys to your Info.plist if you use specific features:
- Background Tasks: Enable "Background fetch" and "Background processing" in Xcode Capabilities.
- Flashlight:
<key>NSCameraUsageDescription</key> <string>Camera access is required to use the flashlight.</string>
Usage #
1. Device Hardware (Flashlight, Brightness, Volume) #
// Toggle Flashlight
await NativeSystemKit.instance.hardware.setFlashlight(true);
// Set System Brightness (Android prompts for permission if needed)
try {
await NativeSystemKit.instance.hardware.setBrightness(0.8);
} on PlatformException catch (e) {
print("Permission missing: ${e.message}");
}
// Listen for system changes (Two-way Sync)
NativeSystemKit.instance.events.eventStream.listen((event) {
if (event == "android.media.VOLUME_CHANGED_ACTION" || event == "BRIGHTNESS_CHANGED") {
// Refresh your UI
NativeSystemKit.instance.hardware.getVolume().then((v) => print("New Volume: $v"));
}
});
2. System Info #
int freeRam = await NativeSystemKit.instance.info.getFreeRam();
int totalSpace = await NativeSystemKit.instance.info.getTotalDiskSpace();
bool isRooted = await NativeSystemKit.instance.info.isDeviceRooted();
print("Free RAM: ${freeRam / 1024 / 1024} MB");
3. Background Service #
// Start a persistent foreground service (Android) / KeepAlive (iOS)
await NativeSystemKit.instance.service.startPersistentService(
title: "My App Service",
content: "Monitoring sensors..."
);
// Stop service
await NativeSystemKit.instance.service.stopPersistentService();
4. Alarms & Scheduling #
// Request permission first (Android 12+)
if (await NativeSystemKit.instance.alarm.requestExactAlarmPermission()) {
await NativeSystemKit.instance.alarm.scheduleExact(
alarmId: "daily_reminder",
triggerTime: DateTime.now().add(const Duration(hours: 1)),
);
}
5. Power Management #
// Keep screen on / CPU running
await NativeSystemKit.instance.power.acquireWakeLock(timeout: 30000); // 30 seconds
// Release
await NativeSystemKit.instance.power.releaseWakeLock();
License #
This project is licensed under the MIT License - see the LICENSE file for details.