Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] mobx won't generate types generated by other generators, and always putting InvalidType in place of the correct type. #926

Closed
andrelrf1 opened this issue Jul 15, 2023 · 8 comments
Assignees
Labels
question Further information is requested wontfix This will not be worked on

Comments

@andrelrf1
Copy link

I started to make a desktop flutter application that needs to access data from a sqlite database with drift, but while doing state management with mobx I realized that the type generated by drift was never recognized by mobx, where instead of the correct type was placed InvalidType. This can be fixed manually, just by replacing the type in the generated file, but as the application grows it is becoming unfeasible to make these changes, because every time we run build_runner the automatically generated files are updated and all changes made manually are lost. Is there any solution to this?

@Heatclift
Copy link

Same issue here, on our case, it puts "InvalidType" instead of "AppLifecycleState" or "Size".

@amondnet
Copy link
Collaborator

dart-lang/build#2701

@ulisseshen
Copy link

Same issue here, with type AppLocalizations from the package I10n import 'package:flutter_gen/gen_l10n/app_localizations.dart';

@amondnet
Copy link
Collaborator

amondnet commented Sep 4, 2023

@andrelrf1 @ulisseshen @Heatclift

This is not a bug in mobx, but depending on your code, build_runner may not work. In my experience, I've had no problems using the libraries mentioned above. I can't help you without reproducible source code.

See below to help you resolve the issue.

https://github.com/dart-lang/build/blob/master/build_config/README.md#adjusting-builder-ordering
dart-lang/build#2701
trevorwang/retrofit.dart#578

@amondnet amondnet added question Further information is requested wontfix This will not be worked on labels Sep 4, 2023
@TobiasPrt
Copy link

For anyone coming across this issue who does not get the - relatively sparse - docs about adjusting the build order, add this to your build.yaml file:

global_options:
  json_serializable:json_serializable:
    runs_before:
      - mobx_codegen:mobx_generator

Replace the reference to json_serialization with the package and builder you are using.

@amondnet
Copy link
Collaborator

amondnet commented Nov 2, 2023

@ulisseshen
https://github.com/FlutterGen/flutter_gen/blob/main/packages/runner/build.yaml

global_options:
  flutter_gen_runner:
    runs_before:
      - mobx_codegen:mobx_generator

@amondnet amondnet closed this as completed Nov 2, 2023
@amondnet amondnet self-assigned this Nov 2, 2023
@andrelrf1
Copy link
Author

Thanks guys, this really worked! Sorry for the delay in responding.

@pavanpodila
Copy link
Member

I think we should make a guide for this on the website...can you please make a short PR for this ? 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

6 participants