fory 0.17.0 copy "fory: ^0.17.0" to clipboard
fory: ^0.17.0 copied to clipboard

Apache Fory Dart runtime

example/example.dart

import 'package:fory/fory.dart';

part 'example.fory.dart';

enum Color {
  red,
  blue,
}

@ForyStruct()
class Person {
  Person();

  String name = '';
  Int32 age = Int32(0);
  Color favoriteColor = Color.red;
  List<String> tags = <String>[];
}

void main() {
  final fory = Fory();
  ExampleFory.register(
    fory,
    Color,
    namespace: 'example',
    typeName: 'Color',
  );
  ExampleFory.register(
    fory,
    Person,
    namespace: 'example',
    typeName: 'Person',
  );

  final person = Person()
    ..name = 'Ada'
    ..age = Int32(36)
    ..favoriteColor = Color.blue
    ..tags = <String>['engineer', 'mathematician'];

  final bytes = fory.serialize(person);
  final roundTrip = fory.deserialize<Person>(bytes);

  print('${roundTrip.name} ${roundTrip.age} ${roundTrip.favoriteColor}');
  print(roundTrip.tags);
}
0
likes
120
points
91
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Apache Fory Dart runtime

Repository (GitHub)
View/report issues
Contributing

License

unknown (license)

Dependencies

analyzer, build, build_config, meta, source_gen

More

Packages that depend on fory