Skip to content

Instantly share code, notes, and snippets.

@rena2019
Created November 4, 2025 14:01
Show Gist options
  • Select an option

  • Save rena2019/ca29ed511cacca57e61b40c341456196 to your computer and use it in GitHub Desktop.

Select an option

Save rena2019/ca29ed511cacca57e61b40c341456196 to your computer and use it in GitHub Desktop.
flutter bytes buffer / byte data
///flutter bytes buffer / byte data
import 'dart:typed_data';
void main() {
final bytes = Uint8List.fromList([0,0,1,0]);
final bd = ByteData.sublistView(bytes, 0, 4);
print(bd.getInt32(0));//256
bd.setInt32(0, 65536);
print(bd.getInt32(0));//65536
print(bytes);//[0, 1, 0, 0]
bd.setInt8(0, 123);
print(bytes);//[123, 1, 0, 0]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment