google/protobuf.dart

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

Closed this issue · 1 comments

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.

osa1 commented

Duplicate of #523, #493, and many others. #790 is fixing this.