File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ final Uint8List? fileContent = await getDocumentContent(uri);
161161/// Handle [fileContent]...
162162
163163/// If the file is intended to be human readable, you can convert the output to [String]:
164- print(String.fromCharCodes (fileContent));
164+ print(utf8.decode (fileContent));
165165```
166166
167167### <samp >getRealPathFromUri</samp >
Original file line number Diff line number Diff line change 1+ import 'dart:convert' ;
2+
13import 'package:fl_toast/fl_toast.dart' ;
24import 'package:flutter/material.dart' ;
35import 'package:flutter/services.dart' ;
@@ -67,7 +69,7 @@ extension ShowDocumentFileContents on DocumentFile {
6769 return Image .memory (content);
6870 }
6971
70- final contentAsString = String . fromCharCodes (content);
72+ final contentAsString = utf8. decode (content);
7173
7274 final fileIsEmpty = contentAsString.isEmpty;
7375
Original file line number Diff line number Diff line change 11import 'dart:async' ;
2+ import 'dart:convert' ;
23import 'dart:io' ;
34import 'dart:typed_data' ;
45
@@ -573,7 +574,7 @@ Future<String?> getDocumentContentAsString(
573574}) async {
574575 final Uint8List ? bytes = await getDocumentContent (uri);
575576
576- return bytes? .apply ((Uint8List a) => String . fromCharCodes (a));
577+ return bytes? .apply ((Uint8List a) => utf8. decode (a));
577578}
578579
579580/// {@template sharedstorage.saf.getDocumentContentAsString}
You can’t perform that action at this time.
0 commit comments