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

required field #948

Open
oo-work opened this issue Nov 29, 2024 · 0 comments
Open

required field #948

oo-work opened this issue Nov 29, 2024 · 0 comments

Comments

@oo-work
Copy link

oo-work commented Nov 29, 2024

message SayRequest{
  required string str1 = 1;
  optional int32 int1 = 2;
}

When I use proto2's required and optional, the code generated by protoc --dart_out=grpc:lib/src/generated -Iprotos .\protos\* is as follows

class SayRequest extends $pb.GeneratedMessage {
  factory SayRequest({
    $core.String? str1,
    $core.int? int1,
  }) {
    final $result = create();
    if (str1 != null) {
      $result.str1 = str1;
    }
    if (int1 != null) {
      $result.int1 = int1;
    }
    return $result;
  }
  SayRequest._() : super();
}

All fields are optional, it does not follow the required as expected

factory SayRequest({
    required String str1,
    int? int1,
  }) 
@oo-work oo-work changed the title required filed required field Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant