To use the Object library in your Flutter/Dart project, add it as a dependency in your pubspec.yaml file and configure it:
pubspec.yaml
dependencies: object: ^1.0.0 object: baseProjectFolder: 'lib' outputFolder: 'model/generated' modelsFile: 'model.g.dart' generationClassSuffix: 'Gen'
Then, run flutter pub get to install the library.
flutter pub get
Configure the classes you will use with the object library.
object
import 'package:flutter/material.dart'; import 'package:object/object.dart'; import 'model/sample.dart'; void main() { /// From your pubspec.yaml configuration: /// /// modelsFile: 'model.g.dart' /// /// generates the [Model] class: Model().instancesForLoad(); runApp(const MyApp()); }
You can include other classes with no @Field annotation but that implement the Object<T> contract of the library.
@Field
Object<T>
Model().instancesForLoad( additional: [ OtherClass(), ], );
Before importing this class you will have to run dart run object:build
dart run object:build
There was an error while loading. Please reload this page.
- Generate Serialization Code
- Create new instances
- Create a list of instances
- Create a map of instances
- Other types of instances
- Conversion safety