sqlite 如何在Flutter中从SQFLite读取数据

dohp0rv5  于 2023-05-18  发布在  SQLite
关注(0)|答案(1)|浏览(157)

我正在使用sqflite包,我想从它读取数据,在表中名为my_table的表中的数据ins,我想读取它的name属性,并在小部件中使用它,如文本小部件这里是我尝试过的\

list = await db.query('my_table', 'name');
     @override
      Widget build(BuildContext context) {
        ScrollController _scrollController = new ScrollController();
        return Scaffold(
          floatingActionButton: FloatingActionButton(
            onPressed: () {
              _scrollController.jumpTo(_scrollController.position.maxScrollExtent);
            },
          ),
          body: Container(
                  color: Colors.blue,
                  height: 1000,
                  width: MediaQuery.of(context).size.width,
                  child: Text('${list}'),
                ),    );
      }
aurhwmvo

aurhwmvo1#

请提供更多信息!
使用SQFLite时:

阅读:

https://github.com/tekartik/sqflite/blob/master/sqflite/doc/sql.md
查询用于阅读表内容。它返回一个map列表。

var list = await db.query('my_table', columns: ['name', 'type']);

我可以推荐这个guide for SQFLite

相关问题