Open dyardy opened 2 years ago
I believe this has to do with the build order of the generated files. I am looking for a solution to this. Is there any way to order the file generation? (drift puts classes in {filename}_g.dart files and these are not discovered by mobx when it runs.
What about moving that custom type to a new file
What about moving that custom type to a new file
That might work however, I would have to run the generator once for the drift/moor generation, then put the files in a new file name then re-run the generation for the mobx generator? (is this what u are suggesting?) The problem is around running the generator the 2nd time, as it probably would try to generate the drift/moor files once again and with same issue.
@dyardy No, I mean write down drift/moor-related code in a.dart and mobx-related code in b.dart. Is it possible?
Hi, I am having the same issue also with drift generation Companion classes. I have confirmed that the order of file generation does not matter. Actually the drift/moor files are not being re-generated in my example (they have no changes). For me, drift and mobx code is already in different files.
I have created an example project to demonstrate the behavior here: https://github.com/washed/mobx_codegen_dynamic_mwe
In this example you can see how the type SomeModelCompanion
(from database.g.dart
) gets incorrectly generated with a return type of dynamic
in the mobx store generated code.
Please let me know if i can help figure this out in any way.
EDIT: I have added a "fake" generated code example by manually creating two files using the part
and part of
syntax (fake_gen.dart
& fake_gen.g.dart
) and here mobx code generation also fails to look up the types from the "generated" code. Is this maybe a more general issue with code generation where the analyzer doesn't follow the "part" files or something similar?
EDIT 2: This seems to be related https://github.com/mobxjs/mobx.dart/issues/246 and was closed without resolution.
I'm having this same problem, does anyone have any updates or solutions for this?
After running flutter packages
pub run build_runner build
to generate code for mobx store I receive this error about dynamic type. I can resolve by changing the dynamic in the generated class to PostedImage how best to resolve this?'_$PostedImageStore.postedImages' ('ObservableFuture<List>? Function()') isn't a valid override of '_PostedImageStore.postedImages' ('ObservableFuture<List>? Function()')
My store
In the generated file the error is coming from the dynamic type identified below. If I replace dynamic with PostedImage type then all is good. My PostedImage is a class is generated from a Drift/Moor class (see below)
I am using versions mobx: ^2.0.6+1 flutter_mobx: ^2.0.4