borsh_annotation 0.3.0 borsh_annotation: ^0.3.0 copied to clipboard
Annotation used to make a Dart object borsh serializable.
Annotations for the borsh generator #
See borsh generator.
This package is still under development, as an example you can use it as follows
@Struct()
class SimpleStruct1 extends BorshStruct {
const SimpleStruct1({
required this.strValue,
required this.int32Value,
required this.fixedIntegersArray,
required this.dynamicStringArray,
});
factory SimpleStruct1.fromBorsh(List<int> bytes) =>
_SimpleStruct1FromBorsh(bytes);
@override
List<int> toBorsh() => _SimpleStruct1ToBorsh(this);
@string
final String strValue;
@i32
final int int32Value;
@Array.fixed(Borsh.u8, length: 3)
final List<int> fixedIntegersArray;
@Array.dynamic(Borsh.string)
final List<String> dynamicStringArray;
}
The generator will generate a .g.dart file that you must include in your file as a part.