webViewListener method

void webViewListener(
  1. dynamic type,
  2. dynamic event
)

Implementation

void webViewListener(type, event) {
  ///刷新页面方法
  ///目前1.0.0版本还不可动态修改内容
  if (type == 1) {
    String? htmlData = event["htmlData"];
    String? htmlBlockData = event["htmlBlockData"];
    String? htmlUrl = event["htmlUrl"];

    if (htmlData != null) {
      mHtmlData = htmlData;
    }
    if (htmlBlockData != null) {
      mHtmlBlockData = htmlBlockData;
    }
    if (htmlUrl != null) {
      mUrl = htmlUrl;
    }
    refresh();
  } else if (type == 2) {
    String? jsMethodName = event["jsMethodName"];

    ///Flutter调用 Html中的Js方法
    loadJsMethod("$jsMethodName('${json.encode(event)}')");
  } else if (type == 3) {
    ///返回历史
    goBack();
  } else if (type == 4) {
    ///返回历史
    goForward();
  }
}