Read and write binary data to postgresql from dart server app
05:20 15 Apr 2026

Dart app (Server side) + shelf + postgres plugin, all latest version.

I'm trying to read / write binary data to/from postgresql table field, the data is a binary protobuf message.

This is how I write the data an it works fine:

result = await dB.execute(r'INSERT INTO accounts (username, data) VALUES ($1,$2);', parameters: ['janedoe',account.writeToBuffer()]);

This is how I read the data, and it works fine:

result = await setupDb.execute(r"SELECT data FROM accounts WHERE username = $1", parameters: ['janedoe']);

Now I need to convert back the binary data to the initial Object, using fromBuffer protbuf function accepting List

Account account = Account.fromBuffer(result[0] as List);

this instruction always fails:

type 'ResultRow' is not a subtype of type 'List' in type cast

How to get List data from the database field?

Any help is appreciated.

postgresql dart protocol-buffers