neuro_realm_generator 1.2.0-3979237ba0d93edcc571bb81776d8889b9b65b01 copy "neuro_realm_generator: ^1.2.0-3979237ba0d93edcc571bb81776d8889b9b65b01" to clipboard
neuro_realm_generator: ^1.2.0-3979237ba0d93edcc571bb81776d8889b9b65b01 copied to clipboard

Generates RealmObject classes from Realm data model classes. This package is part of the very-unofficial Realm Flutter and Realm Dart SDKs.

Realm

License

This project is in the Alpha stage. All API's might change without warning and no guarantees are given about stability. Do not use it in production.

Description #

Dart code generator that generates RealmObject classes based on Realm data model classes using naming conventions.

This package is part of the official Realm Flutter and Realm Dart SDKs https://github.com/realm/realm-dart

Usage #

  • Add a dependency to realm package or realm_dart package to your application.

To generate RealmObjects

  • Run dart run realm generate for Flutter projects

  • Run dart run realm_dart generate for Dart projects

Conventions #

  • Every Dart class annotated with @RealmModel() and named with an underscore like _ClassName, is considered a Realm data model class and the code generator will generate a RealmObject class that can be used with Realm Flutter™ and Realm Dart™.

  • The Dart file containg Realm schema classes needs to have a part defintion name in the format

    part "filename.g.dart".

    For example: In file cars.dart there should be a part definition part "cars.g.dart"

  • The underscore in the class name is requried. class _Car.

  • Every field that references another RealmObject must use the schema class name of that RealmObject. For example:

    class _Car {
      late _Car secondCar;
    }
    
  • The generator will infer the Realm type from the Dart type of every property of the class.

Example #

Filename: cars.dart

part "cars.g.dart"

@RealmModel()
class _Car {
  late String make; //required field
  late String? model; //optional field
  String kilometers = 500; //default value
  late _Car? secondCar; //Object relationship 1:1
  final List<_Car> allOtherCars; //Object relationship 1:Many
}

Debugging #

  • Use the Debug Generator Tests launch config in VS Code. The launch config also has an arg for filtering specifc tests.
The "Dart" name and logo and the "Flutter" name and logo are trademarks owned by Google.
0
likes
120
pub points
0%
popularity

Publisher

unverified uploader

Generates RealmObject classes from Realm data model classes. This package is part of the very-unofficial Realm Flutter and Realm Dart SDKs.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

analyzer, build, build_resolvers, dart_style, neuro_realm_common, source_gen, source_span

More

Packages that depend on neuro_realm_generator