Skip to content

Instantly share code, notes, and snippets.

@Sunbreak
Created March 3, 2020 07:21
Show Gist options
  • Save Sunbreak/da54f6ede4eb5f6a4bd850f1af613225 to your computer and use it in GitHub Desktop.
Save Sunbreak/da54f6ede4eb5f6a4bd850f1af613225 to your computer and use it in GitHub Desktop.

ErrorReport

Target Platform: All

Target OS version/browser: All

Devices: Chrome

WriteBuffer aligment

import 'dart:typed_data';
import 'package:flutter/foundation.dart';
void main() {
final buffer1 = WriteBuffer()
..putUint16(0, endian: Endian.little);
var b1 = buffer1.done().buffer.asUint8List();
print('${b1.length} $b1');
final byteData1 = ByteData(2)
..setUint16(0, 0, Endian.little);
var b2 = byteData1.buffer.asUint8List();
print('${b2.length} $b2');
final buffer2 = WriteBuffer()
..putUint8(0)
..putUint16(0, endian: Endian.little);
var b3 = buffer2.done().buffer.asUint8List();
print('${b3.length} $b3');
final byteData2 = ByteData(3)
..setUint8(0, 0)
..setUint16(1, 0, Endian.little);
var b4 = byteData2.buffer.asUint8List();
print('${b4.length} $b4');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment