getFileSize static method

Future<int> getFileSize(
  1. String filePath
)

Gets file size in bytes, returns 0 if file doesn't exist

Implementation

static Future<int> getFileSize(String filePath) async {
  try {
    final file = File(filePath);
    if (await file.exists()) {
      return await file.length();
    }
    return 0;
  } catch (e) {
    debugPrint('Failed to get file size for $filePath: $e');
    return 0;
  }
}