appendFileAsString static method

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

追加文件内容

Implementation

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