Skip to content

Consider supporting Sets in constructors #54

Closed
@jakemac53

Description

@jakemac53

Consider a class like:

class MyThing {
  final Set<int> myInts;

  MyThing(this.myInts);
}

Today the generated fromJson constructor would end up trying to pass in an Iterable<int> to the constructor, which won't work. The workaround is:

class MyThing {
  final Set<int> myInts;

  MyThing(Iterable<int> myInts) : this.myInts = myInts.toSet();
}

...but ideally that wouldn't be necessary :).

fwiw, for List fields it will automatically call toList on the iterable before passing it in.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions