Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
screenshot
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
screenshot
Commits
1265f8d5
提交
1265f8d5
authored
6月 13, 2021
作者:
Sachin Ganesh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Release 1.1.0
上级
727e4860
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
30 行增加
和
36 行删除
+30
-36
CHANGELOG.md
CHANGELOG.md
+3
-1
README.md
README.md
+17
-3
code1.png
assets/code1.png
+0
-0
code2.png
assets/code2.png
+0
-0
main.dart
example/lib/main.dart
+3
-3
screenshot.dart
lib/screenshot.dart
+6
-28
pubspec.yaml
pubspec.yaml
+1
-1
没有找到文件。
CHANGELOG.md
浏览文件 @
1265f8d5
## [1.1.0] - 13/06/2021
*
Add support for invisible widget capture
## [1.0.0-nullsafety.0] - 10/02/2021
## [1.0.0-nullsafety.0] - 10/02/2021
*
Add nullsafety
*
Add nullsafety
...
@@ -6,7 +9,6 @@
...
@@ -6,7 +9,6 @@
*
support for web and windows
*
support for web and windows
*
Add captureAndSave method.
*
Add captureAndSave method.
## [0.2.0] - 10/06/2020
## [0.2.0] - 10/06/2020
*
Add captureAsUiImage method
*
Add captureAsUiImage method
...
...
README.md
浏览文件 @
1265f8d5
...
@@ -6,7 +6,20 @@ This package wraps your widgets inside [RenderRepaintBoundary](https://docs.flut
...
@@ -6,7 +6,20 @@ This package wraps your widgets inside [RenderRepaintBoundary](https://docs.flut
[
Source
](
https://stackoverflow.com/a/51118088
)
[
Source
](
https://stackoverflow.com/a/51118088
)
<img
src=
"https://github.com/SachinGanesh/screenshot/raw/master/assets/screenshot.gif"
alt=
"screenshot"
width=
"200"
/>
---
<br>
<div
style=
"display: flex;"
>
<div
style=
"flex: 40%; padding: 5px;"
>
<img
src=
"https://github.com/SachinGanesh/screenshot/raw/master/assets/screenshot.gif"
alt=
"screenshot"
/>
</div>
<div
style=
"flex: 60%; padding: 5px;"
>
<p>
Capture a widget part of the widget tree:
</p>
<img
src=
"https://github.com/SachinGanesh/screenshot/raw/master/assets/code1.png"
alt=
"screenshot"
/>
<hr>
<p>
Capture an invisible widget (a widget which is not part of the widget tree):
</p>
<img
src=
"https://github.com/SachinGanesh/screenshot/raw/master/assets/code2.png"
alt=
"screenshot"
/>
</div>
</div>
---
---
## Getting Started
## Getting Started
...
@@ -181,7 +194,7 @@ The solution is to add a small delay before capturing.
...
@@ -181,7 +194,7 @@ The solution is to add a small delay before capturing.
```
dart
```
dart
screenshotController
.
capture
(
delay:
Duration
(
milliseconds:
10
))
screenshotController
.
capture
(
delay:
Duration
(
milliseconds:
10
))
```
```
---
## Known Issues
## Known Issues
-
Platform Views are not supported. (Example
:
Google Maps, Camera etc)
-
Platform Views are not supported. (Example
:
Google Maps, Camera etc)
---
\ No newline at end of file
assets/code1.png
0 → 100644
浏览文件 @
1265f8d5
30.3 KB
assets/code2.png
0 → 100644
浏览文件 @
1265f8d5
38.8 KB
example/lib/main.dart
浏览文件 @
1265f8d5
...
@@ -31,7 +31,7 @@ class MyApp extends StatelessWidget {
...
@@ -31,7 +31,7 @@ class MyApp extends StatelessWidget {
}
}
class
MyHomePage
extends
StatefulWidget
{
class
MyHomePage
extends
StatefulWidget
{
MyHomePage
({
Key
key
,
this
.
title
})
:
super
(
key:
key
);
MyHomePage
({
Key
?
key
,
required
this
.
title
})
:
super
(
key:
key
);
final
String
title
;
final
String
title
;
@override
@override
...
@@ -86,8 +86,8 @@ class _MyHomePageState extends State<MyHomePage> {
...
@@ -86,8 +86,8 @@ class _MyHomePageState extends State<MyHomePage> {
onPressed:
()
{
onPressed:
()
{
screenshotController
screenshotController
.
capture
(
delay:
Duration
(
milliseconds:
10
))
.
capture
(
delay:
Duration
(
milliseconds:
10
))
.
then
((
Uint8List
capturedImage
)
async
{
.
then
((
capturedImage
)
async
{
ShowCapturedWidget
(
context
,
capturedImage
);
ShowCapturedWidget
(
context
,
capturedImage
!
);
}).
catchError
((
onError
)
{
}).
catchError
((
onError
)
{
print
(
onError
);
print
(
onError
);
});
});
...
...
lib/screenshot.dart
浏览文件 @
1265f8d5
...
@@ -32,17 +32,14 @@ class ScreenshotController {
...
@@ -32,17 +32,14 @@ class ScreenshotController {
pixelRatio:
pixelRatio
,
pixelRatio:
pixelRatio
,
delay:
delay
,
delay:
delay
,
);
);
if
(
content
!=
null
)
{
PlatformFileManager
fileManager
=
PlatformFileManager
();
PlatformFileManager
fileManager
=
PlatformFileManager
();
return
fileManager
.
saveFile
(
content
,
directory
,
name:
fileName
);
return
fileManager
.
saveFile
(
content
!,
directory
,
name:
fileName
);
}
return
null
;
}
}
Future
<
Uint8List
>
capture
({
Future
<
Uint8List
?
>
capture
({
double
?
pixelRatio
,
double
?
pixelRatio
,
Duration
delay
:
const
Duration
(
milliseconds:
20
),
Duration
delay
=
const
Duration
(
milliseconds:
20
),
})
{
})
{
//Delay is required. See Issue https://github.com/flutter/flutter/issues/22308
//Delay is required. See Issue https://github.com/flutter/flutter/issues/22308
return
new
Future
.
delayed
(
delay
??
Duration
(
milliseconds:
20
),
()
async
{
return
new
Future
.
delayed
(
delay
??
Duration
(
milliseconds:
20
),
()
async
{
...
@@ -141,7 +138,7 @@ class ScreenshotController {
...
@@ -141,7 +138,7 @@ class ScreenshotController {
class
Screenshot
<
T
>
extends
StatefulWidget
{
class
Screenshot
<
T
>
extends
StatefulWidget
{
final
Widget
?
child
;
final
Widget
?
child
;
final
ScreenshotController
?
controller
;
final
ScreenshotController
controller
;
const
Screenshot
({
const
Screenshot
({
Key
?
key
,
Key
?
key
,
required
this
.
child
,
required
this
.
child
,
...
@@ -160,32 +157,13 @@ class ScreenshotState extends State<Screenshot> with TickerProviderStateMixin {
...
@@ -160,32 +157,13 @@ class ScreenshotState extends State<Screenshot> with TickerProviderStateMixin {
@override
@override
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
// if (widget.controller == null) {
// _controller = ScreenshotController();
// } else
_controller
=
widget
.
controller
;
_controller
=
widget
.
controller
;
}
}
// @override
// void didUpdateWidget(Screenshot oldWidget) {
// // super.didUpdateWidget(oldWidget);
// // if (widget.controller != oldWidget.controller) {
// // widget.controller._containerKey = oldWidget.controller._containerKey;
// // if (oldWidget.controller != null && widget.controller == null)
// // _controller._containerKey = oldWidget.controller._containerKey;
// // if (widget.controller != null) {
// // if (oldWidget.controller == null) {
// // _controller = null;
// // }
// // }
// // }
// }
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
RepaintBoundary
(
return
RepaintBoundary
(
key:
_controller
!
.
_containerKey
,
key:
_controller
.
_containerKey
,
child:
widget
.
child
,
child:
widget
.
child
,
);
);
}
}
...
...
pubspec.yaml
浏览文件 @
1265f8d5
name
:
screenshot
name
:
screenshot
description
:
Flutter Screenshot Package (Runtime). Capture any Widget as an image.
description
:
Flutter Screenshot Package (Runtime). Capture any Widget as an image.
version
:
1.
0.0-nullsafety
.0
version
:
1.
1
.0
homepage
:
https://github.com/SachinGanesh/screenshot
homepage
:
https://github.com/SachinGanesh/screenshot
environment
:
environment
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论