writeFileAsString static method

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

写入文件内容

Implementation

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