yin_webview

为满足自己操作cookie需求

Getting Started

库引用

dependencies:
    yin_webview: ^0.0.5

包引用

import 'package:yin_webview/YinWebViewPlugin.dart';

实现原理

这个是一个调用原生webview实现的工具
通过MethodChannel 实现 flutter与原生通信

使用方式

List<Map<String, String>> cookies = new List();
cookies.add({"k": "hkroles_develop", "v": "buyer%2Cseller%2Ccardseller"});
cookies.add({"k": "hkuid_develop", "v": "1010004"});
    
Navigator.push(
            context,
            new MaterialPageRoute(
              builder: (context) => new YinWebViewPlugin(
                    url: url,
                    actions: <Widget>[
                      IconButton(
                        icon: Icon(Icons.alarm),
                        tooltip: "Alarm",
                        onPressed: () {
                          print("Alarm");
                        },
                      ),
                      PopupMenuButton(
                        itemBuilder: (BuildContext context) =>
                        <PopupMenuItem<String>>[
                          PopupMenuItem<String>(child: Text("热度"), value: "hot",),
                          PopupMenuItem<String>(child: Text("最新"), value: "new",),
                        ],
                        onSelected: (String action) {
                          switch (action) {
                            case "hot":
                              print("hot");
                              break;
                            case "new":
                              print("new");
                              break;
                          }
                        },
                        onCanceled: () {
                          print("onCanceled");
                        },
                      )
                    ],
                    scrollBar: false,
                    cookieList: cookies,
                    loadUrl: (value) {
                      print('test url=$value');
                    },
                    plugin: (YinWebview bean) {
                      if (bean != null) {
                        bean.getCookies(url, (value) {
                          print('test cookies=$value');
                        });
                      }
                    },
                  ),
            ),
          );

Libraries

YinWebViewPlugin
yin_webview