Skip to content

[Bug][proto3] inconsistent behavior of assigning null value for optional string #794

@thanhdatvo

Description

@thanhdatvo
syntax = "proto3";

package test;

message SomeMessage { optional string optional_string = 1; }

When I use this message in dart code like this:

final someMessage = SomeMessage(optionalString: null);
someMessage.optionalString = null; // error

It throwed an error:
"
A value of type 'Null' can't be assigned to a variable of type 'String'.
Try changing the type of the variable, or casting the right-hand type to 'String'
"
I think it should be consistent between initialization and reassign value for message attributes.

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