I want to create a model like the following, but the .g.
file for isar
is not being generated.
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:isar/isar.dart';
part 'model.freezed.dart';
part 'model.g.dart';
@freezed
@Collection(ignore: {'copyWith'})
class Model with _$Model {
const factory Model({
required Id id,
required String name,
}) = _Model;
const Model._();
}
error:
Target of URI hasn't been generated: 'package:my_app/entity/model.g.dart'.
Try running the generator that will generate the file referenced by the URI.
How can I make freezed
and isar
coexist and generate files together?
In your pubspec.yaml file, use latest isar and freezed package,
In your model.dart class, change
Id id int id
Then run this command in your terminal
This will generate both model.freezed.dart, model.g.dart file together.
For breaking in ISAR v4, read it isar 4.0.0-dev.14 changelog.