【发布时间】:2021-03-29 16:30:52
【问题描述】:
我使用 sqflite Open an asset database 将我现有的 database.db 文件添加到我的项目中
(我将此添加到我的 db_helper.dart 文件中的 initializeDB() 函数中。)
没有遇到错误,一切正常,但是......
我想列出项目,但如何从数据库表中获取数据到 ListView?
哪些函数必须添加到db_helper.dart 以及如何从main.dart 调用它们?
这是模型Country.dart文件:
int _id;
String _countryName;
String _image;
//Constructor
Countries(this._id, this._countryName, this._image);
//Gettters
int get id => _id;
String get name => _countryName;
String get image => _image;
// Extract a Product Object from a Map Oject
Countries.fromMapObject(Map<String, dynamic> map) {
this._id = map['country_id'];
this._countryName = map['country_name'];
this._image = map['image'];
}```
【问题讨论】: