rebuild method Null safety

T rebuild(
  1. void updates(
    1. T

Apply updates to a copy of this message.

Throws an ArgumentError if this is not already frozen.

Makes a writable shallow copy of this message, applies the updates to it, and marks the copy read-only before returning it.


T rebuild(void Function(T) updates) {
  if (!isFrozen) {
    throw ArgumentError('Rebuilding only works on frozen messages.');
  final t = toBuilder();
  updates(t as T);
  return t..freeze();