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

Provide a way to control which fields in a content file are mapped to which record fields #6

Open
fujidaiti opened this issue Jul 17, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@fujidaiti
Copy link
Owner

Suppose we have a JSON file such as:

{ "phone_number": "XX-XXX-XXX" }

and want to convert it as:

({ String phoneNumber })

Then, we need to tell the code generator that "phone_number" should be mapped to phoneNumber of String. One idea is to introduce a new annotation like RefKey and use it as:

@EmbedLiteral("my_data.json")
const ({ @RefKey("phone_number") String phoneNumber }) embedding = _$embedding;

Given this source, the generator will dump the following code:

const _$embedding = ( phoneNumber: "XX-XXX-XXX" );
@fujidaiti
Copy link
Owner Author

It appears that annotations on record fields won't be implemented, at least until the macro feature is released.

dart-lang/language#2471 (comment)

@fujidaiti fujidaiti added the enhancement New feature or request label Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant