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

Is possible to have constant values? #88

Closed
BenevidesLecontes opened this issue Jul 6, 2022 · 4 comments
Closed

Is possible to have constant values? #88

BenevidesLecontes opened this issue Jul 6, 2022 · 4 comments
Labels
wontfix This will not be worked on

Comments

@BenevidesLecontes
Copy link

Hi, thanks for your amazing package. I'm wondering if is possible to generate constant variables instead of getters in cases where we don't have interpolation and another dynamic features.

@Tienisto
Copy link
Member

Tienisto commented Jul 6, 2022

Hi,
the generator did generated constant variables a time ago, but I disliked it because hot-reload is not possible

@BenevidesLecontes
Copy link
Author

I understand, but we have some use cases where we need a constant value. We can't use the getter in enhanced enums.

@Tienisto
Copy link
Member

Tienisto commented Jul 7, 2022

So you are only using one locale?
Because the translation variable itself is dynamic depending on the current locale

@Tienisto
Copy link
Member

Tienisto commented Jul 8, 2022

This is how I would implement it to make sure that always the current locale is used:

enum Vehicle {
  car,
  bike;
  
  String get description {
    switch (this) {
      case Vehicle.car:
        return t.vehicle.car;
      case Vehicle.bike:
        return t.vehicle.bike;
    }
  }
}

@Tienisto Tienisto added the wontfix This will not be worked on label Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants