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