device_util_plus 0.0.3
device_util_plus: ^0.0.3 copied to clipboard
`device_util_plus` is a lightweight Flutter package that provides easy access to device information like battery, network and storage.
import 'package:flutter/material.dart';
import 'package:device_util_plus/device_util_plus.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
BatteryUtils.getBatteryLevel().then((result) {
print('_MyAppState.initState : getBatteryLevel : => $result');
});
BatteryUtils.onBatteryLevelChanged.listen((level) {
print('_MyAppState.initState:onBatteryLevelChanged => $level');
});
BatteryUtils.onBatteryStateChanged.listen((status) {
print('_MyAppState.initState:onBatteryStateChanged => $status');
});
NetworkUtils.isConnected().then((result) {
print('_MyAppState.initState : isConnected : => $result');
});
NetworkUtils.onNetworkChange.listen((result) {
print('_MyAppState.initState : onNetworkChange : => $result');
});
StorageUtils.info().then((data) {
print('StorageUtils => ${data.toString()}');
});
DeviceUtils.info().then((data) {
print('DeviceUtils => ${data.toString()}');
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Plugin example app')),
body: Center(
child: ElevatedButton(
onPressed: () {
DeviceUtils.vibrate();
},
child: Text("Test Vibrate"),
),
),
),
);
}
}