flutter - 类型 'QueryRow' 不是类型 'String' 的子类型
flutter - type 'QueryRow' is not a subtype of type 'String'
类型 'QueryRow' 不是类型 'String' 的子类型
当我从 sqflite 检索数据时,我想将它添加到 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;
}
最后,我把函数改成这样:
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
);
}
并且 returned 列表的 return 元素类型是 _InternalLinkedHashMap<String, dynamic>
类型 'QueryRow' 不是类型 'String' 的子类型 当我从 sqflite 检索数据时,我想将它添加到 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;
}
最后,我把函数改成这样:
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
);
}
并且 returned 列表的 return 元素类型是 _InternalLinkedHashMap<String, dynamic>