GetDutchie / brick

An intuitive way to work with persistent data in Dart

Home Page:https://getdutchie.github.io/brick/#/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build_runner runs with problems

hortigado opened this issue · comments

image
image
image
image

Build_runner does not correctly import models. When running build_runner It import the models incorrectly without the /models folder but below it imports them correctly. This causes the adapters to not be created correctly

Hey @hortigado thanks for using Brick. I'm going to consolidate this ticket into #343 and #344 but before I do, how did you get adapters generated with _model_adapter.g.dart (like sell_model or settings_model)?

@tshedor Hi friend. Already found what the error is due to, it is due to the relative imports. In the images we can see the difference when the .request is imported with relative import, it generates the error.
import 'package:porcicultor/brick/models/age.model.request.dart'; Working
import 'balanceado.model.request.dart'; Relative Import not working

image
image

The fastest and most temporary solution would be to remove the relative imports for the brick folder. This would be achieved by creating an analysis_options.yaml file inside the folder and putting the following code.

include: package:flutter_lints/flutter.yaml

linter:
  rules:
    always_use_package_imports: true

@hortigado sorry, I'm a little confused. The error you're getting is a lint error? Or you're unable to complete flutter run without runtime/compile errors?

@tshedor Hi, The models, requests and adapters in the brick.g.dart file are not imported correctly and the request file is not imported correctly in the .adapter.dart.
All this is due to importing the .request.dart as a relative import in our .model.dart
In a project that does not work with relative imports, there is no problem. I get the error because I work with relative imports.
import 'package:porcicultor/brick/models/age.model.request.dart'; Working
import 'balanceado.model.request.dart'; Relative Import not working

@hortigado Could you just use absolute imports within model files?

@tshedor correct that is the solution that I think is the simplest and I mentioned it above.
I think I will give as solved this problem. Regards