storage_all_ggez 1.0.1
storage_all_ggez: ^1.0.1 copied to clipboard
Access most of the storage information with ease any time you want
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:storage_all_ggez/storage_all_ggez.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Storage Telemetry',
theme: ThemeData.dark(useMaterial3: true),
home: const StorageDashboard(),
);
}
}
class StorageDashboard extends StatefulWidget {
const StorageDashboard({super.key});
@override
State<StorageDashboard> createState() => _StorageDashboardState();
}
class _StorageDashboardState extends State<StorageDashboard> {
bool _isLoading = true;
@override
void initState() {
super.initState();
// Initialize cleanly on boot up using your static plugin refresh setup
_triggerRefresh();
}
void _triggerRefresh() {
StorageAllGgez.refresh(
onNotify: () => setState(() {}),
onStateChanged: (loading) => setState(() => _isLoading = loading),
);
}
String _formatGB(int bytes) {
if (bytes <= 0) return 'N/A';
return '${(bytes / (1024 * 1024 * 1024)).toStringAsFixed(2)} GB';
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('⚡ storage_all_ggez Panel'),
actions: [
Padding(
padding: const EdgeInsets.only(right: 16.0),
child: _isLoading
? const SizedBox(
width: 24,
height: 24,
child: CircularProgressIndicator(
strokeWidth: 2.5,
valueColor: AlwaysStoppedAnimation<Color>(Colors.blueAccent),
),
)
: IconButton(
icon: const Icon(Icons.refresh),
onPressed: _triggerRefresh,
),
),
],
),
body: _isLoading && StorageAllGgez.totalBytes == -1
? const Center(child: CircularProgressIndicator())
: Padding(
padding: const EdgeInsets.all(16.0),
child: GridView.count(
crossAxisCount: 2,
crossAxisSpacing: 16,
mainAxisSpacing: 16,
children: [
_buildMetricCard('Total Space', _formatGB(StorageAllGgez.totalBytes), Icons.disc_full),
_buildMetricCard('Free Space', _formatGB(StorageAllGgez.freeBytes), Icons.storage),
_buildMetricCard('Available Space', _formatGB(StorageAllGgez.availableBytes), Icons.cloud_done),
_buildMetricCard('Storage State', StorageAllGgez.storageState, Icons.info_outline),
_buildMetricCard('Is Storage Low?', StorageAllGgez.isStorageLow ? '⚠️ YES' : '✅ NO', Icons.warning_amber),
_buildMetricCard('Is Storage Full?', StorageAllGgez.isStorageFull ? '🚨 CRITICAL' : '✅ NO', Icons.dangerous),
_buildMetricCard('Free Linux Inodes', StorageAllGgez.freeInodes == -1 ? 'Unsupported' : StorageAllGgez.freeInodes.toString(), Icons.terminal),
_buildMetricCard("Free Linux Inodes", "${StorageAllGgez.isEmulated}", Icons.ac_unit_outlined),
],
),
),
);
}
Widget _buildMetricCard(String title, String value, IconData icon) {
return Card(
elevation: 4,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(icon, size: 32, color: Colors.blueAccent),
const SizedBox(height: 10),
Text(
title,
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500, color: Colors.white70),
),
const SizedBox(height: 6),
Text(
value,
style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
],
),
),
);
}
}