我正在寻找这个(https://github.com/tekartik/sqflite/blob/master/doc/opening_asset_db.md),用于填充应用程序已经格式化和需要的数据,仅用于读取功能.
因此,我对在外部CSV文件中已有所有信息时创建SQLite数据库的理解是,在我的应用程序的.dart文件中创建类模型,例如
class User {
int id;
String _firstName;
String _lastName;
String _dob;
User(this._firstName, this._lastName, this._dob);
User.map(dynamic obj) {
this._firstName = obj["firstname"];
this._lastName = obj["lastname"];
this._dob = obj["dob"];
}
String get firstName => _firstName;
String get lastName => _lastName;
String get dob => _dob;
Map<String, dynamic> toMap() {
var map = new Map<String, dynamic>();
map["firstname"] = _firstName;
map["lastname"] = _lastName;
map["dob"] = _dob;
return map;
}
void setUserId(int id) {
this.id = id;
}
}
那么,如果我有一个CSV文件,其中包含所有用户信息(具有与User类相对应的值),我是否可以使用数据库assets资源 来填充信息,然后在Ffltter应用程序中调用它?我知道可能有很多方法可以做到这一点,但是.db文件到底存储的是什么,它是如何格式化的呢?我可以在此.db文件中实现.csv文件吗?