formatFileSize function

String formatFileSize(
  1. BuildContext context,
  2. int bytes
)

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';
  }
}