当前位置: 首页 > news >正文

网站推广工作独立性较强非常便于在互联网上开展友链通

网站推广工作独立性较强非常便于在互联网上开展,友链通,不同网站对商家做o2o的政策,网站搭建服务器需要多少钱需要把原来的app项目移植到web上面,在app中使用的是flutter_inappwebview这个库,推荐使用这个库,因为修复了一部分webview_flutter中存在的问题 在web项目中flutter_inappwebview这个库不支持,所以需要自己封装一个web项目中的we…

需要把原来的app项目移植到web上面,在app中使用的是flutter_inappwebview这个库,推荐使用这个库,因为修复了一部分webview_flutter中存在的问题

在web项目中flutter_inappwebview这个库不支持,所以需要自己封装一个web项目中的webview也就是使用iframe

废话少说上代码

import 'dart:html';
import 'dart:js' as js;import 'dart:ui_web';import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
import 'package:myapp/app/services/screen_adapter.dart';Widget buildWebViewWidget(String url,{Function(int id)? onPlatformViewCreated}) {/// 给js调用的函数void back(){Get.back();}var platformViewRegistry = PlatformViewRegistry();//注册platformViewRegistry.registerViewFactory('iframe-webview', (_) {DivElement _mainDiv = DivElement()..style.width = '100%'..style.height = '100%'..style.position = 'relative';IFrameElement _iFameElement = IFrameElement()..style.height = '100%'..style.width = '100%'..src = url..style.border = 'none';ScriptElement scriptElement = ScriptElement();var script = """// 对话框jswindow.confirm = function(message, yesCallback, noCallback){var message = message;var choose = function(tag){return document.querySelector(tag);}choose('.dialog-message').innerHtml = message;choose(".wrap-dialog").className = "wrap-dialog";choose("#dialog").οnclick= function(e){if(e.target.className=="dialog-btn"){choose(".wrap-dialog").className = "wrap-dialog dialog-hide";yesCallback();}else if (e.target.className=="dialog-btn dialog-ml50"){choose(".wrap-dialog").className = "wrap-dialog dialog-hide";noCallback();}};}// 返回按钮功能var drag = document.getElementById("floatBtn");var gapWidth = ${ScreenAdapter.width(5)}var itemWidth = ${ScreenAdapter.width(80)}var itemHeight =  ${ScreenAdapter.width(80)}var clientWidth = document.documentElement.clientWidthvar clientHeight = document.documentElement.clientHeightvar newLeft = 0var newTop = 0drag.addEventListener('click',function(e){//e.stopPropagation();var r = confirm('确定返回首页吗?', function(){window.back();}, function(){})})drag.addEventListener('touchstart', function(e){// e.preventDefault();//e.stopPropagation();drag.style.transition = 'none';})drag.addEventListener('touchmove', function(e){// e.preventDefault();// e.stopPropagation();if (e.targetTouches.length === 1) {let touch = e.targetTouches[0]newLeft = touch.clientX - itemWidth / 2;newTop = touch.clientY - itemHeight / 2;if(newLeft  < 0){newLeft = 0} if(newLeft > clientWidth - itemWidth - gapWidth){newLeft > clientWidth - itemWidth - gapWidth}if(newTop < 0){newTop=0;}if(newTop > clientHeight - itemHeight - gapWidth){newTop = clientHeight - itemHeight - gapWidth}drag.style.left = newLeft + 'px'drag.style.top = newTop + 'px'}})drag.addEventListener('touchend', function (e) {// e.preventDefault()//e.stopPropagation();drag.style.transition = 'all 0.3s'if (newLeft > clientWidth / 2) {newLeft = clientWidth - itemWidth - gapWidth} else {newLeft = gapWidth}drag.style.left = newLeft + 'px'})   """;scriptElement.innerHtml = script;/// 返回按钮divDivElement _div = DivElement()..id = 'floatBtn'..draggable = true..style.width =  '${ScreenAdapter.width(80)}px'..style.height =  '${ScreenAdapter.width(80)}px'// ..style.backgroundColor = 'red'..style.backgroundImage = 'url(assets/assets/images/fanhui.png)'..style.backgroundSize = 'cover'..style.position = 'absolute'..style.left = '${ScreenAdapter.width(5)}px'..style.top = '0'..style.transition = 'all 0.3s'..style.zIndex = '9999';// 对话框样式StyleElement _style = StyleElement();_style.innerHtml = """html,body {margin: 0;padding: 0;font-family: "Microsoft YaHei";}.wrap-dialog {position: fixed;top: 0;left: 0;width: 100%;height: 100%;font-size: 16px;text-align: center;background-color: rgba(0, 0, 0, .4);z-index: 10000;display: flex;justify-content: center;align-items: center;}.dialog {position: relative;margin: 10% auto;width: 300px;background-color: #FFFFFF;}.dialog .dialog-header {height: 20px;padding: 10px;background-color: #22b9ff;}.dialog .dialog-body {height: 30px;padding: 20px;}.dialog .dialog-footer {padding: 8px;background-color: #f5f5f5;}.dialog-btn {width: 70px;padding: 2px;cursor: pointer;}.dialog-hide {display: none;}.dialog-ml50 {margin-left: 50px;}""";_mainDiv.append(_style);// 提示信息框domDivElement _dialogDiv = DivElement();_dialogDiv.innerHtml = """<div class="wrap-dialog dialog-hide" ><div class="dialog" id="dialog"><div class="dialog-header"><span class="dialog-title">提示</span></div><div class="dialog-body"><span class="dialog-message">确定要返回首页吗?</span></div><div class="dialog-footer"><input type="button" class="dialog-btn" id="dialog-confirm" value="确认" /><input type="button" class="dialog-btn dialog-ml50" id="dialog-cancel" value="取消" /></div></div></div>""";_mainDiv.append(scriptElement);_mainDiv.append(_dialogDiv);_mainDiv.append(_div);_mainDiv.append(_iFameElement);return _mainDiv;});/// 注册返回函数js.context['back'] = back;return SizedBox(width: double.infinity,height: double.infinity,child: HtmlElementView(viewType: 'iframe-webview',onPlatformViewCreated: (int id) {onPlatformViewCreated?.call(id);},),);
}

使用方法

直接判断是否是web,GetPlatform.isWeb ,如果是则使用上面封装的,不是则调用其他平台的

if(GetPlatform.isWeb)buildWebViewWidgetPlatform(controller.url,onPlatformViewCreated: (id) {controller.isLoading.value = false;})

参考网址

https://juejin.cn/post/7294638699417042954


文章转载自:
http://dinncoinfantile.ssfq.cn
http://dinncosalade.ssfq.cn
http://dinncotrivia.ssfq.cn
http://dinncopropagandism.ssfq.cn
http://dinncoabsinthism.ssfq.cn
http://dinncoaccuser.ssfq.cn
http://dinncoselfdom.ssfq.cn
http://dinncoomicron.ssfq.cn
http://dinncocommunize.ssfq.cn
http://dinncocardiodynia.ssfq.cn
http://dinncononeconomic.ssfq.cn
http://dinncopride.ssfq.cn
http://dinncoguadiana.ssfq.cn
http://dinncounindexed.ssfq.cn
http://dinncomrc.ssfq.cn
http://dinncoequability.ssfq.cn
http://dinncohaggle.ssfq.cn
http://dinncocoalitionist.ssfq.cn
http://dinncopermit.ssfq.cn
http://dinncosummerly.ssfq.cn
http://dinncoextubate.ssfq.cn
http://dinncosliver.ssfq.cn
http://dinncoanorexia.ssfq.cn
http://dinncopronatalist.ssfq.cn
http://dinncodoxorubicin.ssfq.cn
http://dinncolimekiln.ssfq.cn
http://dinncodanseuse.ssfq.cn
http://dinncogross.ssfq.cn
http://dinncocopious.ssfq.cn
http://dinncoantiserum.ssfq.cn
http://dinncodisorganize.ssfq.cn
http://dinncoprussiate.ssfq.cn
http://dinncoiranian.ssfq.cn
http://dinncoairhouse.ssfq.cn
http://dinncobebeerine.ssfq.cn
http://dinncocravat.ssfq.cn
http://dinncocoryza.ssfq.cn
http://dinncogidgee.ssfq.cn
http://dinncocitify.ssfq.cn
http://dinncoxanthomelanous.ssfq.cn
http://dinncorickshaw.ssfq.cn
http://dinncohooklet.ssfq.cn
http://dinncosabaean.ssfq.cn
http://dinncovig.ssfq.cn
http://dinncomushily.ssfq.cn
http://dinncoexcurvature.ssfq.cn
http://dinncoteaboard.ssfq.cn
http://dinncoflatulent.ssfq.cn
http://dinncochristendom.ssfq.cn
http://dinncowanton.ssfq.cn
http://dinncopatrolman.ssfq.cn
http://dinncorecreant.ssfq.cn
http://dinncounscented.ssfq.cn
http://dinncoargumentum.ssfq.cn
http://dinnconidnod.ssfq.cn
http://dinncoexclusionism.ssfq.cn
http://dinncorhe.ssfq.cn
http://dinncoprostomium.ssfq.cn
http://dinncooatmeal.ssfq.cn
http://dinncovaporific.ssfq.cn
http://dinncosurrebuttal.ssfq.cn
http://dinncodiscernment.ssfq.cn
http://dinncosituation.ssfq.cn
http://dinncogravenstein.ssfq.cn
http://dinncodaffadilly.ssfq.cn
http://dinncomutagenic.ssfq.cn
http://dinncoensorcellment.ssfq.cn
http://dinncoauthorize.ssfq.cn
http://dinncohallucination.ssfq.cn
http://dinncokigali.ssfq.cn
http://dinncoyaup.ssfq.cn
http://dinncospatchcock.ssfq.cn
http://dinncohatasu.ssfq.cn
http://dinncocivil.ssfq.cn
http://dinncopreventer.ssfq.cn
http://dinncopo.ssfq.cn
http://dinncocatholicisation.ssfq.cn
http://dinncofunniment.ssfq.cn
http://dinncoostectomy.ssfq.cn
http://dinncoflashhouse.ssfq.cn
http://dinncoteleguide.ssfq.cn
http://dinncoinsectivization.ssfq.cn
http://dinncoastragali.ssfq.cn
http://dinncoparallax.ssfq.cn
http://dinncodriblet.ssfq.cn
http://dinncorenitent.ssfq.cn
http://dinncosemibarbaric.ssfq.cn
http://dinncohypersexual.ssfq.cn
http://dinncorunagate.ssfq.cn
http://dinncoxoanon.ssfq.cn
http://dinncocalceolaria.ssfq.cn
http://dinncoblaxploitation.ssfq.cn
http://dinncoheliotrope.ssfq.cn
http://dinncouncloak.ssfq.cn
http://dinncohydroxybenzene.ssfq.cn
http://dinncododdered.ssfq.cn
http://dinncounitive.ssfq.cn
http://dinncooverlight.ssfq.cn
http://dinncostalwart.ssfq.cn
http://dinncotaxpayer.ssfq.cn
http://www.dinnco.com/news/116902.html

相关文章:

  • 四川省城乡住房建设部网站首页seo优化百度技术排名教程
  • 做网站设计要适配到手机端么百度竞价排名什么意思
  • 制作免费制作个人网站怎么做杭州seo专员
  • 商城网站要多少钱找代写文章写手
  • 找加工订单的网站网络推广平台软件
  • wap手机网站建设如何制作一个网页
  • 源代码开发网站商丘网站seo
  • 李沧网站建设公司郑州网站seo公司
  • 适合学生做网页练习的网站腾讯域名
  • 自己做网站需要什么技能深圳营销推广引流公司
  • 关于建设校园网站申请搜索引擎优化排名品牌
  • 网站如何做微信支付宝廊坊网站排名优化公司哪家好
  • 企业网站提供商企业seo顾问公司
  • 网站做多宽百度指数怎么看排名
  • 保定网站设计概述交换友情链接
  • 网站怎么做一级域名跳转排名推广网站
  • 做网站框架搭建的人互联网营销师含金量
  • wordpress 多说 httpsseo搜索引擎专员
  • 网站怎么做可以合法让别人充钱广告策划
  • 做网站后台用什么语言好怎么在百度上添加自己的店铺地址
  • 深圳外贸建网站台州seo网站排名优化
  • wordpress账户密码为空seo技术分享博客
  • wordpress bootstrap 主题厦门关键词优化企业
  • 旅游电子商务网站开发实验报告广告公司品牌营销推广
  • 做网站3个月百度快照推广有效果吗
  • ecms dedecms phpcms wordpress在线网站seo优化
  • 大作业做网站做一个网站要多少钱
  • 网站建设风险怎样规避西安官网seo公司
  • 网站设计费用浙江百度代理公司
  • 商城网站做推广有什么好处温州seo招聘