import 'dart:typed_data'; import 'package:protobuf/protobuf.dart'; Future protobufUpdateBytes( T Function(List) fromBuffer, Uint8List oldBytes, Future Function(T) update) async { final oldObj = fromBuffer(oldBytes); final newObj = await update(oldObj); return Uint8List.fromList(newObj.writeToBuffer()); } Future Function(Uint8List) protobufUpdate( T Function(List) fromBuffer, Future Function(T) update) => (oldBytes) => protobufUpdateBytes(fromBuffer, oldBytes, update);