Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx_webview_flutter
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx_webview_flutter
Commits
3fee7a9e
提交
3fee7a9e
authored
6月 12, 2025
作者:
MrQi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
README.md修改
上级
4726730d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
72 行增加
和
19 行删除
+72
-19
README.md
README.md
+70
-17
custom_controller.dart
lib/custom_webview/view_model/custom_controller.dart
+2
-2
没有找到文件。
README.md
浏览文件 @
3fee7a9e
...
@@ -11,29 +11,81 @@ and the Flutter guide for
...
@@ -11,29 +11,81 @@ and the Flutter guide for
[
developing packages and plugins
](
https://flutter.dev/developing-packages
)
.
[
developing packages and plugins
](
https://flutter.dev/developing-packages
)
.
-->
-->
TODO: Put a short description of the package here that helps potential users
## 开始使用
know whether this package might be useful for them.
## Features
```
yaml
dependencies
:
TODO: List what your package can do. Maybe include images, gifs, or videos.
clx_webview_flutter
:
git
:
## Getting started
url
:
https://t.clxkj.cn/openSourceLibrary/clx_webview_flutter.git
```
TODO: List prerequisites and provide or point to information on how to
start using the package.
## Usage
## Usage
TODO: Include short and useful examples for package users. Add longer examples
### 导入
to
`/example`
folder.
在使用之前,请确保您已经导入了
`clx_webview_flutter`
包。
```
dart
```
dart
const
like
=
'sample
'
;
import
'package:clx_webview_flutter/clx_webview_flutter.dart
'
;
```
```
### 初始化
## Additional information
#### loadRequest:在使用`CustomController`之前,您需要先初始化它。您可以通过调用`loadRequest`方法来加载一个请求。
```
dart
final
CustomController
customController
=
CustomController
.
loadRequest
(
requestedUrl:
Uri
.
parse
(
uri
),
title:
'Captcha'
);
```
#### loadFile:如果您想加载一个本地html,您可以使用`loadFile`方法。
```
dart
final
CustomController
customController
=
CustomController
.
loadFile
(
absoluteFilePath:
'c://path/to/your/file.html'
);
```
#### loadHtmlString:如果您想加载一个html字符串,您可以使用`loadHtmlString`方法。
```
dart
final
CustomController
customController
=
CustomController
.
loadHtmlString
(
htmlString
);
```
#### 添加JavaScript注入
```
dart
Future
<
bool
>
setJavaScriptChannels
(
JavaScriptChannel
channel
)
```
#### 设置标题
```
dart
Future
<
void
>
setTitle
(
String
title
)
```
#### 设置标题样式
```
dart
Future
<
bool
>
setAppBarTextStyle
(
TextStyle
?
style
)
```
### 使用
TODO: Tell users more about the package: where to find more information, how to
#### 获取标题
contribute to the package, how to file issues, what response they can expect
```
dart
from the package authors, and more.
String
title
=
customController
.
controller
.
getTitle
();
```
#### 获取当前url
```
dart
String
currentUrl
=
customController
.
controller
.
getCurrentUrl
();
```
#### 获取当前页面是否可以前进
```
dart
bool
canGoForward
=
customController
.
controller
.
canGoForward
();
```
#### 获取当前页面是否可以后退
```
dart
bool
canGoBack
=
customController
.
controller
.
canGoBack
();
```
#### 前进
```
dart
customController
.
controller
.
goForward
();
```
#### 后退
```
dart
customController
.
controller
.
goBack
();
```
#### 刷新
```
dart
customController
.
controller
.
reload
();
```
#### 加载url
```
dart
customController
.
controller
.
loadUrl
(
url:
Uri
.
parse
(
'https://www.baidu.com'
));
```
\ No newline at end of file
lib/custom_webview/view_model/custom_controller.dart
浏览文件 @
3fee7a9e
...
@@ -15,7 +15,7 @@ class CustomController extends ChangeNotifier {
...
@@ -15,7 +15,7 @@ class CustomController extends ChangeNotifier {
_controller
.
loadRequest
(
requestedUrl
);
_controller
.
loadRequest
(
requestedUrl
);
}
}
CustomController
.
load
File
(
CustomController
.
load
HtmlString
(
{
required
String
html
,
{
required
String
html
,
String
?
baseUrl
,
String
?
baseUrl
,
String
?
title
,
String
?
title
,
...
@@ -26,7 +26,7 @@ class CustomController extends ChangeNotifier {
...
@@ -26,7 +26,7 @@ class CustomController extends ChangeNotifier {
_controller
.
loadHtmlString
(
html
,
baseUrl:
baseUrl
);
_controller
.
loadHtmlString
(
html
,
baseUrl:
baseUrl
);
}
}
CustomController
.
load
HtmlString
({
CustomController
.
load
File
({
required
String
absoluteFilePath
,
required
String
absoluteFilePath
,
String
?
title
,
String
?
title
,
TextStyle
?
appBarTextStyle
,
TextStyle
?
appBarTextStyle
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论