https://www.cnblogs.com/pjl43/p/9866753.html

https://www.jianshu.com/p/55092eb06c17

requests:

https://stackoverflow.com/questions/53101858/handling-cookies-in-flutter

heck out requests, a flutter library to help with modern RESTful http requests (basic cookies support and json)

  • as of now, it uses shared_preferences which is not the best practice (security-wise) to store sensitive data (session-ids etc) Issue #1

pubspec.yaml

dependencies:
requests: ^1.0.0

Usage:

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);

  

https://pub.dartlang.org/packages/dio#cookie-manager

https://github.com/fluttercommunity/flutter_webview_plugin/pull/51

Unfortunately, I was not considering operating LocalStorage from outside WebView.

Although I tried a little investigation,
there seems to be a case in which execution of evalJavascript or access to LocalStorage can not be performed normally due to the timing of WebView startup, the timing of page loading, and so on.

You may be able to avoid it by waiting until the first page loading is completed and then accessing LocalStorage with evalJavascript.

like this.

// On urlChanged stream
StreamSubscription<WebViewStateChanged> _onStateChanged;
_onStateChanged = flutterWebviewPlugin.onStateChanged.listen((WebViewStateChanged state) {
if (mounted) {
if (state.type == WebViewState.finishLoad) {
flutterWebviewPlugin.evalJavascript(
"window.localStorage.setItem('LOCAL_STORAGE','SOMETOKEN');" +
"document.getElementById('showLocalStorageBtn').click();"
);
}
}
});

i hope you will find it helpful.

webview 监听及获取cookie的更多相关文章

  1. Hibernate数据连接不能正常释放的原因,以及在监听中获取apolicationContext上下文

    Hibernate数据库连接不能正常释放: https://blog.csdn.net/u011644423/article/details/44267301 监听中获取applicationCont ...

  2. datePicker 及 timePicker 监听事件 获取用户选择 年月日分秒信息

    public class MainActivity extends AppCompatActivity { private TimePicker timePicker; private DatePic ...

  3. Jquery中input:type=radio的监听,获取设置值

    一.html <div id='demo'> <input type='radio' name='sex' value='男' > <input type='radio' ...

  4. Android中监听webview监听是否加载完成

    之前写过一篇捕获Phoengap的webview事件的方法,主要是在实现了CordovaInterface的Activity中,  在onMessage中根据第一个参数的message name来判断 ...

  5. BroadcoastReceiver之短信到来监听和获取内容

    废话就不说了,新建类继承,然后配置Manifest.xml:如下 <!--需要给一个接收短信的权限 --> <uses-permission android:name="a ...

  6. WebView使用_WebView监听网页下载_DownloadManager使用

    最近在做一个较简单的项目:通过一个webview来显示一个网页的App 这个网页有下载的功能,关于这一功能需要用到两个知识点: 1.webview监听网页的下载链接.(webview默认情况下是没有开 ...

  7. java事件监听

    获取事件监听需要获取实现ActionListener接口的方法, public class SimpleEvent extends JFrame{    private JButton jb=new ...

  8. OC - 18.监听iPhone的网络状态

    使用系统的方法来监听网络状态 系统的方法是通过通知机制来实现网络状态的监听 实现网络状态监听的步骤 定义Reachability类型的成员变量来保存网络的状态 @property (nonatomic ...

  9. 内容观察者 ContentObserver 监听短信、通话记录数据库 挂断来电

    Activity public class MainActivity extends ListActivity {     private TextView tv_info;     private  ...

随机推荐

  1. jquery easyui datagrid 如何第一次点击列标题时是降序排列

    使用 EasyUI的onBeforeLoad事件,在发回到服务器查询之前,修改排序和对应的图标样式. 1.配置回调函数 data-options='onBeforeLoad:fnOnBeforeLoa ...

  2. 换目标啦,初识PHP

    一.初识PHP脚步程序 1.PHP开始标记 <?php 2.PHP结束标记 ?> <?php?> 3.我们的页面最终是通过html,css,js来展示出一个炫丽的界面 4.PH ...

  3. 更为复杂C程序的运行时结构

    运行环境 win 10 企业版 1809 17763.194,MinGW V3.14 32位,Bundled V3.13.2,Bundled GDB V8.2. 在C语言中,栈的方向是从高地址向低地址 ...

  4. kettle获取系统时间

    Date.prototype.Format = function (fmt) { //author: meizz var o = { "M+": this.getMonth() + ...

  5. python learning day01

    python简介 一.python的由来: python的创始人是吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚 ...

  6. MySQL中dblink的实现(通过federated引擎实现)

    最近项目中涉及MySQL数据库视图的创建,需要整合两个位于不同服务器上数据库的内容,就遇到了远程访问数据库的问题.在oracle中可以通过dblink来实现跨本地数据库来访问另外一个数据库中的数据.通 ...

  7. 笔试中常用c++接口

    1.stack:https://www.cnblogs.com/hdk1993/p/5809161.html 使用该容器时需要包含#include<stack>头文件: 定义stack对象 ...

  8. centos7开启80和8080端口

    开启8080端口 firewall-cmd --permanent --add-port=8080/tcp firewall-cmd --reload 重定向80端口到8080端口firewall-c ...

  9. 测试覆盖率工具EclEmma安装与使用

    此文来自于:https://www.cnblogs.com/cnsdhzzl/p/7638883.html EclEmma的简介 一个优秀的开源软件测试工具 eclipse的一个插件 能够对由 Jav ...

  10. 我的FPGA之旅4---led流水灯

    [1]输入端口不能使用reg数据类型,因为reg类型对应的FPGA内部的寄存器.这样理解:reg寄存器具有记忆功能;而wire类型数据就相当于一根连线.input输入信号用wire连线进来就好:out ...