I'm new to flutter and Isar, I want to use Isar for the local DB for my app. When I try to use build_runner to generate the studylog.g.dart file, nothing was generated.
Here's my collection file
import 'package:isar/isar.dart';
part 'studylog.g.dart';
@collection
class Studylog{
Id id = Isar.autoIncrement;
late String videoID;
late DateTime studydate;
}
@collection
class Scores{
Id id = Isar.autoIncrement;
late int q1score;
late int q1total;
late int q2score;
late int q2total;
final studylog = IsarLink<Studylog>();
}
And after I run the fluttter pub run build_runner build
, the output is:
Deprecated. Use `dart run` instead.
[INFO] Generating build script completed, took 286ms
[INFO] Reading cached asset graph completed, took 76ms
[INFO] Checking for updates since last build completed, took 3.1s
[INFO] Running build completed, took 10ms
[INFO] Caching finalized dependency graph completed, took 55ms
[INFO] Succeeded after 72ms with 0 outputs (0 actions)
When I run the dart run build_runner doctor
, I got the following output:
[INFO] Generating build script completed, took 300ms
[WARNING] Builder isar_generator:isar_generator outputs .isar_generator.g.part from .dart which is not specified in the `build.yaml`
I thought may be something goes wrong with the build.yaml.
A file called studylog.g.dart being generated
First, create an empty file named studylog.g.dart next to your studylog.dart file. Then run the command:
dart run build_runner build
If it still doesn't work, delete the studylog.g.dart file and run the following commands in order:
flutter clean
flutter pub get
flutter pub outdated
dart run build_runner build