提交 1265f8d5 authored 作者: Sachin Ganesh's avatar Sachin Ganesh

Release 1.1.0

上级 727e4860
## [1.1.0] - 13/06/2021
* Add support for invisible widget capture
## [1.0.0-nullsafety.0] - 10/02/2021
* Add nullsafety
......@@ -6,7 +9,6 @@
* support for web and windows
* Add captureAndSave method.
## [0.2.0] - 10/06/2020
* Add captureAsUiImage method
......
......@@ -6,7 +6,20 @@ This package wraps your widgets inside [RenderRepaintBoundary](https://docs.flut
[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>&nbsp; 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>&nbsp;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
......@@ -181,7 +194,7 @@ The solution is to add a small delay before capturing.
```dart
screenshotController.capture(delay: Duration(milliseconds: 10))
```
---
## Known Issues
- Platform Views are not supported. (Example: Google Maps, Camera etc)
---
\ No newline at end of file
......@@ -31,7 +31,7 @@ class MyApp extends StatelessWidget {
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
......@@ -86,8 +86,8 @@ class _MyHomePageState extends State<MyHomePage> {
onPressed: () {
screenshotController
.capture(delay: Duration(milliseconds: 10))
.then((Uint8List capturedImage) async {
ShowCapturedWidget(context, capturedImage);
.then((capturedImage) async {
ShowCapturedWidget(context, capturedImage!);
}).catchError((onError) {
print(onError);
});
......
......@@ -32,17 +32,14 @@ class ScreenshotController {
pixelRatio: pixelRatio,
delay: delay,
);
if (content != null) {
PlatformFileManager fileManager = PlatformFileManager();
return fileManager.saveFile(content, directory, name: fileName);
}
return null;
return fileManager.saveFile(content!, directory, name: fileName);
}
Future<Uint8List> capture({
Future<Uint8List?> capture({
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
return new Future.delayed(delay ?? Duration(milliseconds: 20), () async {
......@@ -141,7 +138,7 @@ class ScreenshotController {
class Screenshot<T> extends StatefulWidget {
final Widget? child;
final ScreenshotController? controller;
final ScreenshotController controller;
const Screenshot({
Key? key,
required this.child,
......@@ -160,32 +157,13 @@ class ScreenshotState extends State<Screenshot> with TickerProviderStateMixin {
@override
void initState() {
super.initState();
// if (widget.controller == null) {
// _controller = ScreenshotController();
// } else
_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
Widget build(BuildContext context) {
return RepaintBoundary(
key: _controller!._containerKey,
key: _controller._containerKey,
child: widget.child,
);
}
......
name: screenshot
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
environment:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论