dart.md
August 16, 2026 ยท View on GitHub
Fory Dart provides xlang Object Serialization, generated models, and Fory gRPC.
It is published on pub.dev, requires Dart 3.7 or later, and uses build_runner
to generate serializers.
Verify the Toolchain
dart --version
dart pub --help
Object Serialization
Add Fory and the generator to pubspec.yaml:
dependencies:
fory: 1.6.1
dev_dependencies:
build_runner: ^2.4.0
Create lib/person.dart:
import 'package:fory/fory.dart';
part 'person.fory.dart';
@ForyStruct()
class Person {
Person();
@ForyField(type: Int64Type())
int id = 0;
String name = '';
}
void main() {
final fory = Fory();
PersonForyModule.register(fory, Person, name: 'example.Person');
final input = Person()
..id = 1
..name = 'Alice';
final bytes = fory.serialize(input);
final decoded = fory.deserialize<Person>(bytes);
print(decoded.name);
}
Generate the serializer and run the example:
dart pub get
dart run build_runner build
dart run lib/person.dart
Dart uses xlang mode. Continue with Dart Object Serialization, code generation, web support, and schema evolution.
Other Capabilities
- Fory IDL and Compiler generates Dart models and registration helpers. See Compiler Getting Started and the Dart generated-code guide.
- Fory gRPC uses package:grpc transports with Fory-encoded messages. See Dart gRPC.