有没有一种方法可以在Flutter Web中创建和读取Cookie?
我想知道是否有任何方法可以在flutter中创建和读取cookie,类似于document.cookie
在JavaScript中。这似乎是合乎逻辑的,因为构建时Flutter Web成为JavaScript。
I am wondering if there is any way to create and read cookies in Flutter, similar to document.cookie
in Javascript. It seems logical since Flutter Web becomes Javascript when built.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试此
导入'dart:html';
final cookie = document.cookie;
此将返回字符串,如
“ key = value; key2 = value”
如果需要数据作为映射,则应使用拆分和映射方法提取键:值形式为
:
用于设置cookie
try this
import 'dart:html';
final cookie=document.cookie;
this will return string like
"key=value; key2=value"
if you need the data as Map , you should use split and map method to extract the key:value form it
like:
for setting a cookie
如果DART
:HTML给出flutter Web
使用此dart软件包
Just to add one thing to the above answer
if dart:html gives error with flutter web
use this Dart package