getDocumentContentAsString function

Future<String?> getDocumentContentAsString(
  1. Uri uri, {
  2. bool throwIfError = false,
})

Helper method to generate the file path of the given uri

See Get real path from URI, Android KitKat new storage access framework for details.

Implementation

Future<String?> getDocumentContentAsString(
  Uri uri, {
  bool throwIfError = false,
}) async {
  final Uint8List? bytes = await getDocumentContent(uri);

  return bytes?.apply((Uint8List a) => utf8.decode(a));
}