readFileAsString static method

Future<String> readFileAsString(
  1. String filePath, {
  2. bool catchException = true,
})

读取文件内容

Implementation

static Future<String> readFileAsString(String filePath, {bool catchException = true}) async {
  try {
    final file = File(filePath);
    return await file.readAsString();
  } catch (e) {
    if (catchException) {
      return '';
    } else {
      rethrow;
    }
  }
}