formatFileSize function
Implementation
String formatFileSize(BuildContext context, int bytes) {
if (bytes >= 1024 * 1024 * 1024) {
return '${(bytes / (1024 * 1024 * 1024)).toStringAsFixed(0)} gb';
} else if (bytes >= 1024 * 1024) {
return '${(bytes / (1024 * 1024)).toStringAsFixed(0)} mb';
} else if (bytes >= 1024) {
return '${(bytes / 1024).toStringAsFixed(0)} kb';
} else {
return '$bytes bytes';
}
}