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

Deprecate Enum Methods in Favor of Dart’s Upcoming Enum Shorthand #560

Open
3 tasks
tilucasoli opened this issue Feb 28, 2025 · 0 comments
Open
3 tasks

Comments

@tilucasoli
Copy link
Collaborator

tilucasoli commented Feb 28, 2025

Description

Currently, Mix relies on custom enum methods to define and access specific values. However, the Dart language team is planning to introduce enum shorthand syntax, which will provide a more native way to handle enum values without requiring additional methods.

Maintaining custom enum methods after this update would lead to unnecessary, as this custom methods were implemented to simplify the usage.

Proposed Changes

  1. Deprecate all existing enum methods across Mix.
  2. Remove the need for @MixableEnumUtility() annotation, as enum shorthand will provide a more concise syntax.
  3. Reduce the number of functions in the API, making the framework easier to maintain and lowering support costs.

Before

$flex.direction.horizontal()

After

$flex.direction(Axis.horizontal)

Future with Enum Shorthand

$flex.direction(.horizontal)

Impact Analysis

Benefits

  • Removes unnecessary custom methods declaration and will align with future Dart lang futures. It will improve the maintainability due to the decreasing of methods

Potential Drawbacks

  • Breaking Changes for Existing Codebases
  • Dependence on Dart’s Enum Shorthand Timeline.

Implementation Plan

Tasks

  • Remove the @MixableEnumUtility annotation and all the code gen related
  • Guarantee that all enum attributes are implementing the call method with the respective enum parameter
  • Update Documentation

Testing Strategy

There is no specific strategy

Additional Considerations

Boolean Attributes

Currently, boolean attributes utilize a specific utility that implements .on and .off methods. We propose removing these methods in favor of a more straightforward implementation that aligns with the new enum format. This change align the syntax.
Proposed Changes:

Before

text.textHeightBehavior.heightToLastDescent.on(),

After

$text.textHeightBehavior.heightToLastDescent(true),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant