flutter-类型' queryrow'不是类型的子类型' string'

发布于 2025-01-18 18:38:47 字数 355 浏览 0 评论 0原文

类型“QueryRow”不是类型“String”的子类型 当我从 sqflite 检索数据时,我想将其添加到小部件

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; 
} 

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; 
} 

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼中杀气 2025-01-25 18:38:47

最后我把函数改成这样:

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
    );
}

返回列表元素的返回类型为_InternalLinkedHashMap

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>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文