store list of doubles in moor BlobColumn


I want to use BlobColumn of moor package for storing a list of integer and a list of doubles.
I have no trouble saving integer list because blob type in Uint8List. but when I’m storing double list I get this error:

error: The argument type 'List<double>' can't be assigned to the parameter type 'Uint8List'.

I couldn’t find any document or examples about saving list of any objects in blob column for moor package.

any help would be appreciated.


finally I get to solve my problem and write down these two helpers and write these two methods to convert data for inserting and reading in BlobColumn of database

  List<num> convertUint8ListToDoubleList(Uint8List uint8list) {
    var bdata = ByteData.view(uint8list.buffer);
    return List.generate(
        (uint8list.length / 8).round(), (index) => bdata.getFloat64(index * 8));

  Uint8List convertDoubleListToUint8List(List<num> doubleList) {
    var uint8List = new Uint8List(8 * doubleList.length);
    var bdata = new ByteData.view(uint8List.buffer);
    for (int i = 0; i < doubleList.length; i++) {
      bdata.setFloat64(i * 8, doubleList[i]);
    return uint8List;

Answered By – DNS

Answer Checked By – David Marino (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *