flutter_html 和 WebView 解析html 和 build.gradle源码
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:dio/dio.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:html/dom.dart' as dom; class FlutterHtml extends StatefulWidget{
FlutterHtml({Key key});
_FlutterHtml createState() => _FlutterHtml();
} class _FlutterHtml extends State {
var _html = [];
@override
initState() {
super.initState();
_getData();
}
_getData() async{
var response = await Dio().get('http://www.phonegap100.com/appapi.php?a=getPortalArticle&aid=20');
var res = json.decode(response.data)['result'];
setState(() {
_html = res;
});
print(res);
}
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(title: Text('FlutterHtml'),),
body: ListView(
children: <Widget>[
Html(
data: "${ _html.length > 0 ? _html[0]['content'] : 1}",
//Optional parameters:
padding: EdgeInsets.all(8.0),
backgroundColor: Colors.white70,
defaultTextStyle: TextStyle(fontFamily: 'serif'),
linkStyle: const TextStyle(
color: Colors.redAccent,
),
onLinkTap: (url) {
// open url in a webview
},
onImageTap: (src) {
// Display the image in large form.
},
customTextStyle: (dom.Node node, TextStyle baseStyle) {
if (node is dom.Element) {
switch (node.localName) {
case "p":
return baseStyle.merge(TextStyle(height: 2, fontSize: 20));
}
}
return baseStyle;
},
)
],
)
);
}
}
minSdkVersion 最小版本为17 在app文件夹下面的build.gradle 如果报错就替换 build.gradle如高版本flutter_inappbrowser出错 就使用flutter_inappbrowser: ^1.2.1
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
} def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
} def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
} def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
} apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android {
compileSdkVersion 28 sourceSets {
main.java.srcDirs += 'src/main/kotlin'
} lintOptions {
disable 'InvalidPackage'
} defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.itying.flutter_app01"
minSdkVersion 17
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
} flutter {
source '../..'
} dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
WebView 案例代码
import 'package:flutter/material.dart';
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart'; class WebView extends StatefulWidget{
WebView({Key key});
_WebView createState() => _WebView();
} class _WebView extends State {
@override
initState() {
super.initState();
}
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
appBar: AppBar(title: Text('webView'),),
body: Column(
children: <Widget>[
Expanded(
child: InAppWebView(
initialUrl: "http://www.phonegap100.com/newscontent.php?aid=198",
),
)
]
)
);
}
}
flutter_html 和 WebView 解析html 和 build.gradle源码的更多相关文章
- 如何用Android Studio查看build.gradle源码
上一篇博客里讲过 build.gradle 里的每一行代码基本都是在调用一个方法,既然是这样,我们就可以用 android studio(下面简称as) 去查看它源码的方法注释说明,这样就可以理解每个 ...
- OpenHarmony移植案例: build lite源码分析之hb命令__entry__.py
摘要:本文介绍了build lite 轻量级编译构建系统hb命令的源码,主要分析了_\entry__.py文件. 本文分享自华为云社区<移植案例与原理 - build lite源码分析 之 hb ...
- Android AsyncTask完全解析,带你从源码的角度彻底理解
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/11711405 我们都知道,Android UI是线程不安全的,如果想要在子线程里进 ...
- [转]Android事件分发机制完全解析,带你从源码的角度彻底理解(上)
Android事件分发机制 该篇文章出处:http://blog.csdn.net/guolin_blog/article/details/9097463 其实我一直准备写一篇关于Android事件分 ...
- 【转】Android事件分发机制完全解析,带你从源码的角度彻底理解(下)
转载请注明出处:http://blog.csdn.net/guolin_blog/article/details/9153761 记得在前面的文章中,我带大家一起从源码的角度分析了Android中Vi ...
- Spring Security 解析(七) —— Spring Security Oauth2 源码解析
Spring Security 解析(七) -- Spring Security Oauth2 源码解析 在学习Spring Cloud 时,遇到了授权服务oauth 相关内容时,总是一知半解,因 ...
- [学习总结]7、Android AsyncTask完全解析,带你从源码的角度彻底理解
我们都知道,Android UI是线程不安全的,如果想要在子线程里进行UI操作,就需要借助Android的异步消息处理机制.之前我也写过了一篇文章从源码层面分析了Android的异步消息处理机制,感兴 ...
- Gradle之Gradle 源码分析(四)
Gradle 的启动 constructTaskGraph runTasks finishBuild gradle 脚本如何编译和执 插件调用流程 一.Gradle 的启动 1.1 整体实现图 1.2 ...
- Android ListView工作原理完全解析,带你从源码的角度彻底理解
版权声明:本文出自郭霖的博客,转载必须注明出处. 目录(?)[+] Adapter的作用 RecycleBin机制 第一次Layout 第二次Layout 滑动加载更多数据 转载请注明出处:h ...
随机推荐
- 剑指offer-基础练习-增删节点-链表
/* 链表基本操作: 插入节点和删除节点 */ /* 思路: 使用指向链表的头指针,这样在新插入节点后,头指针不会改变 */ struct ListNode{ int value; ListNode* ...
- 0010 基于DRF框架开发(03 模型序列化器)
序列化器:是指从数据库提取数据,转化前端所需要的数据格式并返回到前端. 反序列化器:是指把前端传回的数据,转换成数据库需要的格式,存入数据库. DRF提供了两种序列化器: 模型序列化器:是指和模型关联 ...
- Parity game POJ - 1733 带权并查集
#include<iostream> #include<algorithm> #include<cstdio> using namespace std; <& ...
- 金蝶云星空BOS开发视频分享
https://vip.kingdee.com/school/implementCourseOnline
- PP: Articial Intelligence—TheRevolution Hasn’t HappenedYet
From Michael I. Jordan As with many phrases that cross over from technical academic fields into gene ...
- 二叉堆(2)LeftistHeap
左倾堆,用于堆的快速合并. 规则: ① 节点的键值小于或等于它的左右子节点的键值. ② 节点的左孩子的NPL >= 右孩子的NPL. ③ 节点的NPL = 它的右孩子的NPL + 1. 测试文件 ...
- 单调栈(POJ2559)
Description A histogram is a polygon composed of a sequence of rectangles aligned at a common base l ...
- win10文件夹 无法显示当前所有者 管理员都不行
1.在win10系统桌面上,任务栏,右键,单击任务管理器. 2.单击性能. 3.单击打开资源监视器. 4.在单击CPU标签,然后再“关联的句柄”右侧的搜索框中输入要删除的文件夹名.例:tre文件夹名. ...
- Struts2学习-jsp中超链接传参问题
今天在学习过程中对struts2中超链接的传参问题产生了一些疑惑,不明白jsp中的超链接如何将参数传到Action方法中去的. <s:iterator value="categorys ...
- ubuntu系统定时运行 crontab
1,crontab是个啥? ubuntu系统自带cron工具,cron是一个系统上的定时工具,用它的好处在于,不同的程序可以用同一个计时器,这样就省得不同程序各自sleep了,另外它还支持比较多的个性 ...