Skip to content

Generated Dart code expects PbMap instead of Map which is hard to create #975

Closed
@gryznar

Description

@gryznar

Previously it was:

class Foo extends $pb.GeneratedMessage {
  factory Foo({
    $core.Map<$core.String, Bar>? bars,
  }) {
    final $result = create();
    if (bars!= null) {
      $result.bars.addAll(bars);
    }
    return $result;
  }
  ...
}

now it is:

class Foo extends $pb.GeneratedMessage {
  factory Foo({
    $pb.PbMap<$core.String, Bar>? bars,
  }) {
    final $result = create();
    if (bars!= null) {
      $result.bars.addAll(bars);
    }
    return $result;
  }
  ...
}

Creating PbMap manually is very problematic, as it expects 2 ints (one for key and one for value). Personally I don't know how to obtain them. Situation is much simpler with PbList which just exposes .from(List<E> from) constructor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions