我一直在尝试让用户登录并使用 dart 在 flutter 中注册 http。我想以某种方式让用户使用 session 或 cookie 留在应用程序中。有人尝试过吗?
最佳答案
查看 requests
- 截至目前,它使用 shared_preferences这不是存储敏感数据( session ID 等)的最佳做法(安全方面)Issue #1
pubspec.yaml
dependencies:
requests: ^1.0.0
用法:
import 'package:requests/requests.dart';
// ...
// this will persist cookies
await Requests.post("https://example.com/api/v1/login", body: {"username":"...", "password":"..."} );
// this will re-use the persisted cookies
dynamic data = await Requests.get("https://example.com/api/v1/stuff", json: true);
关于http - 如何在 flutter 中使用 session 用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52620895/