Build Status Pub

Typed data structures in Dart. Loosely based on js-struct.

This package is in development and currently can be previewed using a mirrors-based implementation, and is not suitable for production use or use within a Flutter or Web binary. The end goal is seamless IPC-like communication for Isolates, binary data, and more.


import 'package:struct/mirrors.dart';

abstract class SimpleStruct implements Struct {
  factory SimpleStruct() = _SimpleStructImpl;

  int myChar;

  int myShort;

  int myInt;

class _SimpleStructImpl extends MirrorsStruct implements SimpleStruct {}

void main() {
  var struct = new SimpleStruct();
  simple.myChar = 'a'.codeUnitAt(0);
  simple.myShort = 12;
  simple.myInt = 34567;

How it works

While the user interacts with a Struct using getters/setters, behind the scenes values are read and write to a ByteBuffer, a sequence of bytes in memory.

Read more about typed_arrays in the browser.