Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
screenshot
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
screenshot
Commits
adfb120a
提交
adfb120a
authored
5月 11, 2019
作者:
Sachin Ganesh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
-- 0.1.1
上级
0f1579cf
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
143 行增加
和
73 行删除
+143
-73
Dart_Packages.xml
.idea/libraries/Dart_Packages.xml
+2
-12
Flutter_Plugins.xml
.idea/libraries/Flutter_Plugins.xml
+1
-1
workspace.xml
.idea/workspace.xml
+49
-10
CHANGELOG.md
CHANGELOG.md
+4
-0
README.md
README.md
+25
-15
Podfile
example/ios/Podfile
+2
-0
project.pbxproj
example/ios/Runner.xcodeproj/project.pbxproj
+8
-4
Info.plist
example/ios/Runner/Info.plist
+2
-0
main.dart
example/lib/main.dart
+25
-12
pubspec.yaml
example/pubspec.yaml
+1
-0
screenshot.dart
lib/screenshot.dart
+23
-18
pubspec.yaml
pubspec.yaml
+1
-1
没有找到文件。
.idea/libraries/Dart_Packages.xml
浏览文件 @
adfb120a
...
...
@@ -6,7 +6,6 @@
<value>
<list>
<option
value=
"$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.1.0/lib"
/>
<option
value=
"$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.0.8/lib"
/>
</list>
</value>
</entry>
...
...
@@ -56,7 +55,6 @@
<value>
<list>
<option
value=
"$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.5/lib"
/>
<option
value=
"$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.3+1/lib"
/>
</list>
</value>
</entry>
...
...
@@ -77,7 +75,7 @@
<entry
key=
"path_provider"
>
<value>
<list>
<option
value=
"$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-
0.5.0+1
/lib"
/>
<option
value=
"$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-
1.1.0
/lib"
/>
</list>
</value>
</entry>
...
...
@@ -92,7 +90,6 @@
<value>
<list>
<option
value=
"$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.2/lib"
/>
<option
value=
"$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.1/lib"
/>
</list>
</value>
</entry>
...
...
@@ -121,7 +118,6 @@
<value>
<list>
<option
value=
"$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.0.0/lib"
/>
<option
value=
"$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-1.6.8/lib"
/>
</list>
</value>
</entry>
...
...
@@ -143,7 +139,6 @@
<value>
<list>
<option
value=
"$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.4/lib"
/>
<option
value=
"$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.2/lib"
/>
</list>
</value>
</entry>
...
...
@@ -164,27 +159,22 @@
</option>
</properties>
<CLASSES>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.0.8/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.1.0/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/boolean_selector-1.0.4/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/charcode-1.1.2/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/collection-1.14.11/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/cupertino_icons-0.1.2/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.3+1/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.5/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/meta-1.1.6/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/path-1.6.2/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-
0.5.0+1
/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-
1.1.0
/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/pedantic-1.5.0/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.1/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.2/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/source_span-1.5.5/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.9.3/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-1.6.8/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.0.0/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.0.4/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.1.0/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.2/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.4/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/typed_data-1.1.6/lib"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib"
/>
...
...
.idea/libraries/Flutter_Plugins.xml
浏览文件 @
adfb120a
<component
name=
"libraryTable"
>
<library
name=
"Flutter Plugins"
type=
"FlutterPluginsLibraryType"
>
<CLASSES>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-
0.5.0+1
"
/>
<root
url=
"file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-
1.1.0
"
/>
</CLASSES>
<JAVADOC
/>
<SOURCES
/>
...
...
.idea/workspace.xml
浏览文件 @
adfb120a
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"AndroidLogFilters"
>
<option
name=
"TOOL_WINDOW_CUSTOM_FILTER"
value=
"fb"
/>
<option
name=
"TOOL_WINDOW_CONFIGURED_FILTER"
value=
"No Filters"
/>
</component>
<component
name=
"CMakeSettings"
>
...
...
@@ -9,15 +10,7 @@
</configurations>
</component>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"27574137-5472-4670-9669-d8e092348fe1"
name=
"Default"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/.idea/libraries/Dart_Packages.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/libraries/Dart_Packages.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/libraries/Flutter_Plugins.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/libraries/Flutter_Plugins.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/example/ios/Runner.xcodeproj/project.pbxproj"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/example/ios/Runner.xcodeproj/project.pbxproj"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/example/lib/main.dart"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/example/lib/main.dart"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/pubspec.lock"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/pubspec.lock"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/screenshot.iml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/screenshot.iml"
afterDir=
"false"
/>
</list>
<list
default=
"true"
id=
"27574137-5472-4670-9669-d8e092348fe1"
name=
"Default"
comment=
""
/>
<ignored
path=
"$PROJECT_DIR$/.dart_tool/"
/>
<ignored
path=
"$PROJECT_DIR$/.idea/"
/>
<ignored
path=
"$PROJECT_DIR$/.pub/"
/>
...
...
@@ -69,6 +62,10 @@
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"98"
>
<caret
line=
"403"
column=
"71"
selection-start-line=
"403"
selection-start-column=
"71"
selection-end-line=
"403"
selection-end-column=
"71"
/>
<folding>
<element
signature=
"e#1512#1539#0"
expanded=
"true"
/>
<element
signature=
"e#1680#1693#0"
expanded=
"true"
/>
</folding>
</state>
</provider>
</entry>
...
...
@@ -96,6 +93,7 @@
<foldersAlwaysOnTop
value=
"true"
/>
</navigator>
<panes>
<pane
id=
"Scope"
/>
<pane
id=
"AndroidView"
/>
<pane
id=
"ProjectPane"
>
<subPane>
...
...
@@ -125,7 +123,6 @@
</subPane>
<option
name=
"show-excluded-files"
value=
"false"
/>
</pane>
<pane
id=
"Scope"
/>
<pane
id=
"PackagesPane"
/>
</panes>
</component>
...
...
@@ -250,6 +247,44 @@
<option
name=
"myLimit"
value=
"2678400000"
/>
</component>
<component
name=
"editorHistoryManager"
>
<entry
file=
"file://$PROJECT_DIR$/test/screenshot_test.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"135"
>
<caret
line=
"11"
column=
"5"
selection-start-line=
"11"
selection-start-column=
"5"
selection-end-line=
"11"
selection-end-column=
"5"
/>
<folding>
<element
signature=
"e#0#48#0"
expanded=
"true"
/>
</folding>
</state>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/lib/screenshot.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"615"
>
<caret
line=
"48"
column=
"35"
selection-start-line=
"48"
selection-start-column=
"35"
selection-end-line=
"48"
selection-end-column=
"35"
/>
</state>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/example/lib/main.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"465"
>
<caret
line=
"34"
column=
"41"
selection-start-line=
"34"
selection-start-column=
"41"
selection-end-line=
"34"
selection-end-column=
"41"
/>
<folding>
<element
signature=
"e#0#17#0"
expanded=
"true"
/>
</folding>
</state>
</provider>
</entry>
<entry
file=
"file://$USER_HOME$/Library/Android/sdk/sources/android-25/android/os/MessageQueue.java"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"6045"
>
<caret
line=
"403"
column=
"71"
selection-start-line=
"403"
selection-start-column=
"71"
selection-end-line=
"403"
selection-end-column=
"71"
/>
<folding>
<element
signature=
"e#1512#1539#0"
expanded=
"true"
/>
<element
signature=
"e#1680#1693#0"
expanded=
"true"
/>
</folding>
</state>
</provider>
</entry>
<entry
file=
"file://$PROJECT_DIR$/test/screenshot_test.dart"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"135"
>
...
...
@@ -512,6 +547,10 @@
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"98"
>
<caret
line=
"403"
column=
"71"
selection-start-line=
"403"
selection-start-column=
"71"
selection-end-line=
"403"
selection-end-column=
"71"
/>
<folding>
<element
signature=
"e#1512#1539#0"
expanded=
"true"
/>
<element
signature=
"e#1680#1693#0"
expanded=
"true"
/>
</folding>
</state>
</provider>
</entry>
...
...
CHANGELOG.md
浏览文件 @
adfb120a
## [0.1.0] - 11/05/2019
*
20 Millisecond delay has been added. See issue https://github.com/flutter/flutter/issues/22308
*
Example app can now save images directly to Gallery (using https://github.com/hui-z/image_gallery_saver)
## [0.1.0] - 09/05/2019
*
changed path_provider version to ^1.1.0
...
...
README.md
浏览文件 @
adfb120a
...
...
@@ -61,20 +61,21 @@ Example:
),
body:
Container
(
child:
new
Center
(
child:
new
Column
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
Screenshot
(
//Screenshot Widget
controller:
screenshotController
,
//asign Controller
//wrap the widgets that you want to capture as image
child:
<
Widget
>[
Text
(
'You have pushed the button this many times:'
+
_counter
.
toString
(),
),
FlutterLogo
(),
],
Screenshot
(
controller:
screenshotController
,
child:
Column
(
children:
<
Widget
>[
Text
(
'You have pushed the button this many times:'
+
_counter
.
toString
(),
),
FlutterLogo
(),
],
),
),
_imageFile
!=
null
?
Image
.
file
(
_imageFile
)
:
Container
(),
],
),
...
...
@@ -84,18 +85,23 @@ Example:
onPressed:
()
{
_incrementCounter
();
_imageFile
=
null
;
screenshotController
.
capture
().
then
((
File
image
)
{
screenshotController
.
capture
()
.
then
((
File
image
)
async
{
//print("Capture Done");
setState
(()
{
_imageFile
=
image
;
});
}).
catchError
((
onError
){
final
result
=
await
ImageGallerySaver
.
save
(
image
.
readAsBytesSync
());
// Save image to gallery, Needs plugin https://pub.dev/packages/image_gallery_saver
print
(
"File Saved to Gallery"
);
}).
catchError
((
onError
)
{
print
(
onError
);
});
},
tooltip:
'Increment'
,
child:
Icon
(
Icons
.
add
),
),
),
// This trailing comma makes auto-formatting nicer for build methods.
);
}
```
...
...
@@ -114,6 +120,10 @@ screenshotController.capture(
);
```
## Saving images to Gallery
If you want to save captured image to Gallery, Please use https://github.com/hui-z/image_gallery_saver
Example app uses the same to save screenshots to gallery.
## Note:
Captured image may look pixelated. You can overcome this issue by setting value for
**pixelRatio**
...
...
example/ios/Podfile
浏览文件 @
adfb120a
...
...
@@ -33,6 +33,7 @@ def parse_KV_file(file, separator='=')
end
target
'Runner'
do
use_frameworks!
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system
(
'rm -rf .symlinks'
)
...
...
@@ -63,6 +64,7 @@ end
post_install
do
|
installer
|
installer
.
pods_project
.
targets
.
each
do
|
target
|
target
.
build_configurations
.
each
do
|
config
|
config
.
build_settings
[
'SWIFT_VERSION'
]
=
'4.2'
config
.
build_settings
[
'ENABLE_BITCODE'
]
=
'NO'
end
end
...
...
example/ios/Runner.xcodeproj/project.pbxproj
浏览文件 @
adfb120a
...
...
@@ -19,7 +19,7 @@
97C146FC1CF9000F007C117D
/* Main.storyboard in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
97C146FA1CF9000F007C117D
/* Main.storyboard */
;
};
97C146FE1CF9000F007C117D
/* Assets.xcassets in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
97C146FD1CF9000F007C117D
/* Assets.xcassets */
;
};
97C147011CF9000F007C117D
/* LaunchScreen.storyboard in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
97C146FF1CF9000F007C117D
/* LaunchScreen.storyboard */
;
};
FA535D5D71EC7D63F66FE7B4
/* libPods-Runner.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
345327055FDFC8D549E0BDD0
/* libPods-Runner.a
*/
;
};
A933A441C6953B1715F82792
/* Pods_Runner.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FF0A07070FEC091E88E0B925
/* Pods_Runner.framework
*/
;
};
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
...
...
@@ -40,7 +40,6 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2
/* GeneratedPluginRegistrant.h */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
GeneratedPluginRegistrant.h
;
sourceTree
=
"<group>"
;
};
1498D2331E8E89220040F4C2
/* GeneratedPluginRegistrant.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
GeneratedPluginRegistrant.m
;
sourceTree
=
"<group>"
;
};
345327055FDFC8D549E0BDD0
/* libPods-Runner.a */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
archive.ar
;
includeInIndex
=
0
;
path
=
"libPods-Runner.a"
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
3B3967151E833CAA004F5970
/* AppFrameworkInfo.plist */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text.plist.xml
;
name
=
AppFrameworkInfo.plist
;
path
=
Flutter/AppFrameworkInfo.plist
;
sourceTree
=
"<group>"
;
};
3B80C3931E831B6300D905FE
/* App.framework */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
wrapper.framework
;
name
=
App.framework
;
path
=
Flutter/App.framework
;
sourceTree
=
"<group>"
;
};
7AFA3C8E1D35360C0083082E
/* Release.xcconfig */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.xcconfig
;
name
=
Release.xcconfig
;
path
=
Flutter/Release.xcconfig
;
sourceTree
=
"<group>"
;
};
...
...
@@ -55,6 +54,7 @@
97C146FD1CF9000F007C117D
/* Assets.xcassets */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
folder.assetcatalog
;
path
=
Assets.xcassets
;
sourceTree
=
"<group>"
;
};
97C147001CF9000F007C117D
/* Base */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file.storyboard
;
name
=
Base
;
path
=
Base.lproj/LaunchScreen.storyboard
;
sourceTree
=
"<group>"
;
};
97C147021CF9000F007C117D
/* Info.plist */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
text.plist.xml
;
path
=
Info.plist
;
sourceTree
=
"<group>"
;
};
FF0A07070FEC091E88E0B925
/* Pods_Runner.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
includeInIndex
=
0
;
path
=
Pods_Runner.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
...
...
@@ -64,7 +64,7 @@
files
=
(
9705A1C61CF904A100538489
/* Flutter.framework in Frameworks */
,
3B80C3941E831B6300D905FE
/* App.framework in Frameworks */
,
FA535D5D71EC7D63F66FE7B4
/* libPods-Runner.a
in Frameworks */
,
A933A441C6953B1715F82792
/* Pods_Runner.framework
in Frameworks */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
...
...
@@ -74,7 +74,7 @@
92179A0594A73D07322FD9B6
/* Frameworks */
=
{
isa
=
PBXGroup
;
children
=
(
345327055FDFC8D549E0BDD0
/* libPods-Runner.a
*/
,
FF0A07070FEC091E88E0B925
/* Pods_Runner.framework
*/
,
);
name
=
Frameworks
;
sourceTree
=
"<group>"
;
...
...
@@ -237,10 +237,14 @@
inputPaths
=
(
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh"
,
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework"
,
"${BUILT_PRODUCTS_DIR}/image_gallery_saver/image_gallery_saver.framework"
,
"${BUILT_PRODUCTS_DIR}/path_provider/path_provider.framework"
,
);
name
=
"[CP] Embed Pods Frameworks"
;
outputPaths
=
(
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework"
,
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_gallery_saver.framework"
,
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider.framework"
,
);
runOnlyForDeploymentPostprocessing
=
0
;
shellPath
=
/bin/sh
;
...
...
example/ios/Runner/Info.plist
浏览文件 @
adfb120a
...
...
@@ -26,6 +26,8 @@
<
string
>
LaunchScreen
<
/string
>
<
k
e
y
>
UIMainStoryboardFile
<
/k
e
y
>
<
string
>
Main
<
/string
>
<
k
e
y
>
NSPhotoLibraryAddUsageDescription
<
/k
e
y
>
<
string
>
Save
Photos
to
Folder
<
/string
>
<
k
e
y
>
UISupportedInterfaceOrientations
<
/k
e
y
>
<
a
rr
a
y
>
<
string
>
UIInterfaceOrientationPortrait
<
/string
>
...
...
example/lib/main.dart
浏览文件 @
adfb120a
import
'dart:io'
;
import
'dart:typed_data'
;
import
'package:flutter/material.dart'
;
import
'package:screenshot/screenshot.dart'
;
import
'package:image_gallery_saver/image_gallery_saver.dart'
;
void
main
(
)
=>
runApp
(
MyApp
());
...
...
@@ -86,20 +88,21 @@ class _MyHomePageState extends State<MyHomePage> {
),
body:
Container
(
child:
new
Center
(
child:
new
Column
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
Screenshot
(
controller:
screenshotController
,
child:
Column
(
children:
<
Widget
>[
Text
(
'You have pushed the button this many times:'
+
_counter
.
toString
(),
),
FlutterLogo
(),
],
)),
controller:
screenshotController
,
child:
Column
(
children:
<
Widget
>[
Text
(
'You have pushed the button this many times:'
+
_counter
.
toString
(),
),
FlutterLogo
(),
],
),
),
_imageFile
!=
null
?
Image
.
file
(
_imageFile
)
:
Container
(),
],
),
...
...
@@ -109,11 +112,16 @@ class _MyHomePageState extends State<MyHomePage> {
onPressed:
()
{
_incrementCounter
();
_imageFile
=
null
;
screenshotController
.
capture
().
then
((
File
image
)
{
screenshotController
.
capture
(
delay:
Duration
(
milliseconds:
10
))
.
then
((
File
image
)
async
{
//print("Capture Done");
setState
(()
{
_imageFile
=
image
;
});
final
result
=
await
ImageGallerySaver
.
save
(
image
.
readAsBytesSync
());
print
(
"File Saved to Gallery"
);
}).
catchError
((
onError
)
{
print
(
onError
);
});
...
...
@@ -123,4 +131,9 @@ class _MyHomePageState extends State<MyHomePage> {
),
// This trailing comma makes auto-formatting nicer for build methods.
);
}
_saved
(
File
image
)
async
{
final
result
=
await
ImageGallerySaver
.
save
(
image
.
readAsBytesSync
());
print
(
"File Saved to Gallery"
);
}
}
example/pubspec.yaml
浏览文件 @
adfb120a
...
...
@@ -13,6 +13,7 @@ environment:
sdk
:
"
>=2.1.0
<3.0.0"
dependencies
:
image_gallery_saver
:
^1.1.0
screenshot
:
path
:
../
flutter
:
...
...
lib/screenshot.dart
浏览文件 @
adfb120a
...
...
@@ -14,28 +14,33 @@ class ScreenshotController {
ScreenshotController
()
{
_containerKey
=
GlobalKey
();
}
Future
<
File
>
capture
({
String
path
=
""
,
double
pixelRatio:
1
,
})
async
{
try
{
RenderRepaintBoundary
boundary
=
this
.
_containerKey
.
currentContext
.
findRenderObject
();
ui
.
Image
image
=
await
boundary
.
toImage
(
pixelRatio:
pixelRatio
);
ByteData
byteData
=
await
image
.
toByteData
(
format:
ui
.
ImageByteFormat
.
png
);
Uint8List
pngBytes
=
byteData
.
buffer
.
asUint8List
();
if
(
path
==
""
)
{
final
directory
=
(
await
getApplicationDocumentsDirectory
()).
path
;
String
fileName
=
DateTime
.
now
().
toIso8601String
();
path
=
'
$directory
/
$fileName
.png'
;
Duration
delay:
const
Duration
(
milliseconds:
20
)
})
{
//DElay is required. See Issue https://github.com/flutter/flutter/issues/22308
return
new
Future
.
delayed
(
delay
,
()
async
{
try
{
RenderRepaintBoundary
boundary
=
this
.
_containerKey
.
currentContext
.
findRenderObject
();
ui
.
Image
image
=
await
boundary
.
toImage
(
pixelRatio:
pixelRatio
);
ByteData
byteData
=
await
image
.
toByteData
(
format:
ui
.
ImageByteFormat
.
png
);
Uint8List
pngBytes
=
byteData
.
buffer
.
asUint8List
();
if
(
path
==
""
)
{
final
directory
=
(
await
getApplicationDocumentsDirectory
()).
path
;
String
fileName
=
DateTime
.
now
().
toIso8601String
();
path
=
'
$directory
/
$fileName
.png'
;
}
File
imgFile
=
new
File
(
path
);
await
imgFile
.
writeAsBytes
(
pngBytes
).
then
((
onValue
)
{});
return
imgFile
;
}
catch
(
Exception
)
{
throw
(
Exception
);
}
File
imgFile
=
new
File
(
path
);
await
imgFile
.
writeAsBytes
(
pngBytes
).
then
((
onValue
)
{});
return
imgFile
;
}
catch
(
Exception
)
{
throw
(
Exception
);
}
});
}
}
...
...
pubspec.yaml
浏览文件 @
adfb120a
name
:
screenshot
description
:
Flutter Screenshot Package (Runtime). Capture any Widget as an image.
version
:
0.1.
0
version
:
0.1.
1
author
:
Sachin Ganesh <sachinganesh@outlook.com>
homepage
:
https://github.com/SachinGanesh/screenshot
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论