Flutter 基于蜂巢数据库的颤振网络
我用flatter开发了演示web应用程序,并将其上传到我的服务器上,我使用在web应用程序上存储一些数据 最近我发现,当我打开web应用程序并在其中存储一些数据时, 如果我再次使用不同的浏览器,我看不到以前存储的数据, 看起来FlatterWeb上的配置单元将数据存储在客户端缓存的某个地方 我现在有3个问题:Flutter 基于蜂巢数据库的颤振网络,flutter,dart,flutter-dependencies,flutter-web,flutter-hive,Flutter,Dart,Flutter Dependencies,Flutter Web,Flutter Hive,我用flatter开发了演示web应用程序,并将其上传到我的服务器上,我使用在web应用程序上存储一些数据 最近我发现,当我打开web应用程序并在其中存储一些数据时, 如果我再次使用不同的浏览器,我看不到以前存储的数据, 看起来FlatterWeb上的配置单元将数据存储在客户端缓存的某个地方 我现在有3个问题: 配置单元数据库的位置在哪里?如何手动访问 我如何解决这个问题,并将数据存储在我的服务器上,使每个用户都能看到相同的数据 我应该在服务器端使用Dart来实现这个目标吗?如果是,我可以
- 配置单元数据库的位置在哪里?如何手动访问
- 我如何解决这个问题,并将数据存储在我的服务器上,使每个用户都能看到相同的数据
- 我应该在服务器端使用Dart来实现这个目标吗?如果是,我可以从哪里开始查找好的文档
void _initHiveDB() async {
if (_isDBInited) {
return;
}
if(!kIsWeb){
final documentsDirectory = await Path_Provider.getApplicationDocumentsDirectory();
Hive.init(documentsDirectory.path);
}
Hive.registerAdapter(ComplaintModelAdapter(), 0);
_isDBInited = true;
}
Future<bool> saveNewComplaint(ComplaintModel complaintModel)async{
try{
if(_complaintBox==null||!_complaintBox.isOpen){
_complaintBox = await Hive.openBox('Complaints');
}
else{
_complaintBox = Hive.box('Complaints');
}
_complaintBox.add(complaintModel);
return true;
}
catch(exc){
return false;
}
}
Future<List<ComplaintModel>> loadAllComplaints() async {
try{
if(_complaintBox==null||!_complaintBox.isOpen){
_complaintBox = await Hive.openBox('Complaints');
}
else{
_complaintBox = Hive.box('Complaints');
}
//Box<ComplaintModel> complaintBox = await Hive.openBox('Complaints');
//Box<ComplaintModel> complaintBox = await Hive.box('Complaints');
List<ComplaintModel> complaints = _complaintBox.values.toList();
return complaints;
}
catch(exc){
return null;
}}
void\u initHiveDB()异步{
如果(_isdbinite){
返回;
}
如果(!kIsWeb){
final Documents目录=等待路径_Provider.GetApplicationDocuments目录();
init(documentsDirectory.path);
}
registerAdapter(ComplaintModelAdapter(),0);
_isdbinite=true;
}
未来SAVENECUMPAINT(投诉模型投诉模型)异步{
试一试{
if(_complaintBox==null | |!_complaintBox.isOpen){
_complaintBox=等待Hive.openBox(“投诉”);
}
否则{
_投诉箱=蜂巢箱(“投诉”);
}
_complaintBox.add(complaintModel);
返回true;
}
捕获(exc){
返回false;
}
}
Future loadAllComplaints()异步{
试一试{
if(_complaintBox==null | |!_complaintBox.isOpen){
_complaintBox=等待Hive.openBox(“投诉”);
}
否则{
_投诉箱=蜂巢箱(“投诉”);
}
//Box complaintBox=等待Hive.openBox(“投诉”);
//Box complaintBox=等待蜂箱。Box(“投诉”);
列出投诉=_complaintBox.values.toList();
返回投诉;
}
捕获(exc){
返回null;
}}
Hive工作正常,它是一个嵌入式数据库,必须为不同的浏览器提供不同的数据库。如果您需要在云中共享这些信息,您应该寻找其他类型的数据库。云数据库将是解决方案。例如,google工具中有免费的解决方案,或者创建连接到数据库SQL的API。HiveDB是一个本地数据库,在移动平台中使用平台的文件系统。在浏览器中,它使用。因此,您无法在所有用户之间共享数据。为了实现这一点,您可以使用Firebase的云Firestore作为后端数据库。