storage_space_info 1.0.0
storage_space_info: ^1.0.0 copied to clipboard
A Flutter plugin to get total, used and free storage for Android and iOS.
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:storage_space_info/storage_space_info.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
double total = 0;
double used = 0;
double free = 0;
@override
void initState() {
super.initState();
initPlatformState();
}
Future<void> initPlatformState() async {
var data = await StorageSpaceInfo.getStorage();
total = data.totalStorage;
used = data.totalUsedStorage;
free = data.totalFreeStorage;
setState(() {});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Plugin example app')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Total Storage :- ${total.toStringAsFixed(2)}"),
SizedBox(height: 30),
Text("Total Used Storage :- ${used.toStringAsFixed(2)}"),
SizedBox(height: 30),
Text("Total Free Storage :- ${free.toStringAsFixed(2)}"),
],
),
),
),
);
}
}