readFile static method

Future<String> readFile(
  1. String path
)

Read file content safely

Implementation

static Future<String> readFile(String path) async {
  try {
    final file = File(path);
    if (!await file.exists()) {
      throw Exception('File not found: $path');
    }
    return await file.readAsString();
  } catch (e) {
    throw Exception('Error reading file $path: $e');
  }
}