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

Mutable Union types not mutable #675

Closed
Var1377 opened this issue May 28, 2022 · 0 comments
Closed

Mutable Union types not mutable #675

Var1377 opened this issue May 28, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@Var1377
Copy link

Var1377 commented May 28, 2022

When using @unfreezed, union types don't allow mutation

Example:

@unfreezed
class ExampleADT with _$ExampleADT {
  const ExampleADT._();

  factory ExampleADT.firstVariant({required int arg1}) = _ExampleFirstVariant;
  factory ExampleADT.secondVariant({required String arg2}) = _ExampleSecondVariant;

  factory ExampleADT.fromJson(Map<String, dynamic> json) => _$ExampleADTFromJson(json);

  void mutate() => this.map(firstVariant: (value) => value.arg1 = 2, secondVariant: (value) => value.arg2 = "1");
}

Expected Behaviour: Mutation

Actual Behaviour:

There isn’t a setter named 'arg1' in class '_ExampleFirstVariant'.
Try correcting the name to reference an existing setter, or declare the setter.

There isn’t a setter named 'arg2' in class '_ExampleSecondVariant'.
Try correcting the name to reference an existing setter, or declare the setter.
@Var1377 Var1377 added bug Something isn't working needs triage labels May 28, 2022
rrousselGit added a commit that referenced this issue Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants