dart:io:File class inconsistently using both List<int>
and Uint8List
to represent bytes
#39947
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
closed-invalid
Closed as we don't believe the reported issue is generally actionable
library-io
type-question
A question about expected behavior or functionality
Dart SDK Version (
dart --version
)Dart VM version: 2.7.0 (Unknown timestamp) on "linux_x64"
Description
The
dart:io:File
class currently represents bytes using the newUint8List
type in the following methods:The related
RandomAccessFile
also usesUint8List
in the following methods:Confusingly,
dart:io:File
also usesList<int>
to represent byte sequences:And
RandomAccessFile
also has methods usingList<int>
:Expected behaviour
Sequences of bytes should be represented using the same data type in all methods of a class, and hopefully soon, in the whole SDK. I understand that the transition to the more efficient
Uint8List
has not been fully completed yet, but have this kind of inconsistency even within single classes is very concerning.Notice that
Utf8Codec
seems to still useList<int>
for everything, as well as other closely-related types likeIOSink
, making the ecosystem broken in many places.For example, it seems that some packages have already been updated to use
Uint8List
in some methods wherdart:io
still usesList<int>
. Seepackage:file
's File for example, which has been usingUint8List
for several versions now (since at least 5.0.8 from what I can see) but is currently unusable with the stable Dart SDK because of this, even if I try to use older versions like 5.0.7, because then some methods that should useUint8List
still are usingList<int>
.The text was updated successfully, but these errors were encountered: