From a82635436551fe871f8eb2817ec5a993b1a56080 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Fri, 10 Nov 2023 23:54:40 +0000 Subject: [PATCH] Document that writeAsBytes truncates values beyond 0..255 Closes https://github.com/dart-lang/sdk/pull/53782 GitOrigin-RevId: 5453268e4ebad23c4085efbab78b53cec551930d Change-Id: I7804cbe65c93bc34f56db6da7bc68aa1ef4e9303 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330944 Commit-Queue: Brian Quinlan Reviewed-by: Lasse Nielsen --- sdk/lib/io/file.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sdk/lib/io/file.dart b/sdk/lib/io/file.dart index 193cfe75883a..32db8689087e 100644 --- a/sdk/lib/io/file.dart +++ b/sdk/lib/io/file.dart @@ -520,6 +520,11 @@ abstract interface class File implements FileSystemEntity { /// file if it already exists. In order to append the bytes to an existing /// file, pass [FileMode.append] as the optional mode parameter. /// + /// The elements of [bytes] should be integers in the range 0 to 255. + /// Any integer, which is not in that range, is converted to a byte before + /// being written. The conversion is equivalent to doing + /// `value.toUnsigned(8)`. + /// /// If the argument [flush] is set to `true`, the data written will be /// flushed to the file system before the returned future completes. Future writeAsBytes(List bytes, @@ -533,6 +538,11 @@ abstract interface class File implements FileSystemEntity { /// the file if it already exists. In order to append the bytes to an existing /// file, pass [FileMode.append] as the optional mode parameter. /// + /// The elements of [bytes] should be integers in the range 0 to 255. + /// Any integer, which is not in that range, is converted to a byte before + /// being written. The conversion is equivalent to doing + /// `value.toUnsigned(8)`. + /// /// If the [flush] argument is set to `true` data written will be /// flushed to the file system before returning. ///