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

The annotation 'JsonKey' can only be used on fields or getters dart (invalid_annotation_target) #85

Closed
1 task done
Prn-Ice opened this issue Feb 11, 2022 · 2 comments

Comments

@Prn-Ice
Copy link

Prn-Ice commented Feb 11, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Models created that contain a JsonKey produce the following lint warning.

The annotation 'JsonKey' can only be used on fields or getters dart(invalid_annotation_target)

This is fixed by adding

// ignore_for_file: invalid_annotation_target

To the top of the file.

Expected Behavior

No lint warning

Steps To Reproduce

  1. Create a new dart project
  2. Create a freezed model using the plugin from the json text

Version

3.5.7

Relevant JSON syntax

{
    "status": "success",
    "data": {
        "id": "577cf6ee-3cf4-4a55-8652-d8f5dd8d3375",
        "first_name": "Walter",
        "last_name": "Udoh",
        "middle_name": null,
        "email": "[email protected]",
        "username": "walter",
        "country": "NG",
        "email_verified_at": "2021-04-27T15:51:05.000Z",
        "phone_number": "+2347049974371",
        "phone_number_verified_at": "2021-04-05T10:57:57.000Z",
        "google_id": null,
        "facebook_id": null,
        "pin_set_at": "2021-07-01T21:28:44.000Z",
        "referral_code": "liiVF",
        "referred_by": "9e0aa010-860b-4286-acf6-22007c88b713",
        "last_logged_in_at": "2022-02-07T12:09:12.000Z",
        "status": null,
        "created_at": "2021-03-02T16:02:27.000Z",
        "updated_at": "2022-02-07T12:09:12.000Z",
        "currency": {
            "code": "NGN",
            "decimals": 2,
            "name": "Nigerian naira",
            "number": "566",
            "symbol": ""
        }
    }
}

Anything else?

No response

@iamarnas
Copy link
Collaborator

@Prn-Ice Hey there 👋

This is known issue and it come not from the extension side. You can read here how to fix it 👉 fix.

@iamarnas iamarnas pinned this issue Feb 12, 2022
@iamarnas iamarnas changed the title [BUG] The annotation 'JsonKey' can only be used on fields or getters dart(invalid_annotation_target) The annotation 'JsonKey' can only be used on fields or getters dart (invalid_annotation_target) Feb 12, 2022
@Prn-Ice
Copy link
Author

Prn-Ice commented Feb 12, 2022

I see thanks

@Prn-Ice Prn-Ice closed this as completed Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants