Closed au-top closed 1 year ago
Can I ask you to provide the usage code, where the error occurs specifically?
@k-paxian Sorry, I found out that the dart_json_mapper in my shared code base is inconsistent with the current project version. But so far I have a question about the multi-project setup, how do I go about the same version when sharing the code base with multiple projects For example I have three projects project: a b c
they depend on a version constraint dart_json_mapper: ^2.2.2
I can't guarantee that the versions in their actual .lock
files are in sync
And because I need to execute dart pub run build_runner build
for each project, it will cause some problems, how can I ensure that the versions in the three projects are consistent, or can I support one
export 'package:free_store_share/protocol/protocol_package.dart';
export 'config_def.dart';
export './json_mapper_export.mapper.g.dart' show jsonMapperExportGeneratedAdapter, initializeJsonMapper, initializeJsonMapperAsync;
void main() {}
I can import a class
with @jsonSerializable
from another project and then call dart pub run build_runner build
in one project to generate a xxx.mapper.g.dart
file unique to this project instead of via xxxxGeneratedAdapter
Adapter
because Adapter
means I need to execute dart pub run build_runner build
separately for each project that has dart_json_mapper
Well it depends on your assumptions about that shared code, and how many peers are working on that shared projects? how often those shared projects has changes? etc.
You have all the options, from the monolith usage inside the destination app project, then you'll need to maintain only one generated file. Or you could go on full isolation to separate the code across the a,b,c,... shared projects. Depends on your project setup, and expected code life cycle - what suits your project purpose better. There is no silver bullet for that.
As well you could automate the dart pub run build_runner build
step using CI/CD tools, etc.
Version 2.2.5 cannot encode/decode normally
But 2.2.4+2 can
I haven't tested 2.2.5+1 because my dependency doesn't support 2.2.5+1
Is this a bug?
he error info
code
If someone encounters the same problem as me, you can try to lock the version lock version to 2.2.4+2
or