简体   繁体   English

如何使用 Flutter 将数据 SQLite(离线)发送到服务器 MySQL?

[英]How can I send data SQLite (offline) to server MySQL using Flutter?

When there is no signal I use offline mode by storing data to the device (SQLite).当没有信号时,我通过将数据存储到设备 (SQLite) 来使用离线模式。 After there is a signal I try to send the data to the Mysql server.有信号后,我尝试将数据发送到 Mysql 服务器。

How can I send data from SQLite (offline mode) to MySQL server?如何将数据从 SQLite(离线模式)发送到 MySQL 服务器?

create a DB similar to your sqflite db's table in a remote server.在远程服务器中创建一个类似于 sqflite db 表的数据库。 then, create a rest api using your desired language(php is easy to start).然后,使用您想要的语言创建一个 rest api(php 很容易上手)。 then, when the app is connected to internet, use HTTP client to send the data to the remote server.然后,当应用程序连接到互联网时,使用 HTTP 客户端将数据发送到远程服务器。

you can use a code like below for the post data call:您可以使用如下代码进行后期数据调用:

Future<dynamic> post(String url, {Map headers, body, encoding}) {
print(url);
print(body);
return http
    .post(BASE_URL+url, body: body, headers: headers, encoding: encoding)
    .then((http.Response response) {
  final String res = response.body;
  final int statusCode = response.statusCode;

  print(res);

  if (statusCode < 200 || statusCode > 400 || json == null) {
    throw new Exception("Error while fetching data");
  }
  return _decoder.convert(res);
});
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将离线模式集成到我的Flutter应用程序中? 我正在使用MySQL服务器 - How to integrate the offline mode in my flutter application? I'm using MySQL server 任何人都可以使用 flutter 中的 android 工作室从 apk 中查看离线 sqlite db 数据吗? - Can any body able to see offline sqlite db data from apk using android studio in flutter? 如何将数据发送到 flutter 中的文本字段 - How can i send data to textfield in flutter 我如何创建一个 model 并将数组数据插入 sqlite flutter - how i can create a model and insert array data into sqlite flutter 如何将数据保存到sqlite当没有网络并在flutter中恢复网络连接后发送到服务器 - How to save data to sqlite When There is no network and send to server once the network connection is restored in flutter 我如何将数据从 Smartwatch 发送到 Flutter/companion 应用程序 - How can i send data from Smartwatch to Flutter/companion app 如果我使用firestore离线存储聊天应用程序的数据,我还需要sqlite,颤振吗 - If I use firestore offline to store the data for the chat app, do I still need sqlite, flutter 如何将数据发送到 Flutter 中的匿名 class? - How can I send data to an anonymous class in Flutter? 如何将数据从 ListView 发送到 Flutter 中的 TextField? - How can I send data from ListView into TextField in Flutter? 如何在 flutter 中使用低蓝牙能量发送数据 - How do I send data using low bluetooth energy in flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM