readFileAsString method

Future<String?> readFileAsString({
  1. String? fileName,
  2. String? path,
})

Reads the file and returns its UTF-8 content. Returns null when the file does not exist.

Implementation

Future<String?> readFileAsString({String? fileName, String? path}) async {
  final Uint8List? bytes = await readFileAsBytes(
    fileName: fileName,
    path: path,
  );
  return bytes == null ? null : utf8.decode(bytes);
}