'flutter - type 'QueryRow' is not a subtype of type 'String'

type 'QueryRow' is not a subtype of type 'String' when I retrieved data from sqflite, and I want to add it to widget

Future<List> getSpecificForm({String tableName, formId}) async { 
  final db = await database; 
  final List<Map<String, dynamic>> result = await db.rawQuery( 'SELECT * FROM $tableName WHERE id=? ORDER BY id DESC', [formId]); 
  return result; 
} 


Solution 1:[1]

Finally, I changed the function like this:

Future<List> getSpecificForm({String tableName, formId}) async {
    final db = await database;
    final List<Map<String, dynamic>> result =  await db.rawQuery('SELECT * FROM $tableName WHERE id=?', [formId]);

    return List<Map<String, dynamic>>.generate(
        result.length, (index) => Map<String, dynamic>.from(result[index]),
        growable: true
    );
}

and the return type of elements of the returned list is _InternalLinkedHashMap<String, dynamic>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tullo_x86