提交 adfb120a authored 作者: Sachin Ganesh's avatar Sachin Ganesh

-- 0.1.1

上级 0f1579cf
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
<value> <value>
<list> <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.1.0/lib" />
<option value="$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.0.8/lib" />
</list> </list>
</value> </value>
</entry> </entry>
...@@ -56,7 +55,6 @@ ...@@ -56,7 +55,6 @@
<value> <value>
<list> <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.5/lib" />
<option value="$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.3+1/lib" />
</list> </list>
</value> </value>
</entry> </entry>
...@@ -77,7 +75,7 @@ ...@@ -77,7 +75,7 @@
<entry key="path_provider"> <entry key="path_provider">
<value> <value>
<list> <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> </list>
</value> </value>
</entry> </entry>
...@@ -92,7 +90,6 @@ ...@@ -92,7 +90,6 @@
<value> <value>
<list> <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.2/lib" />
<option value="$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/quiver-2.0.1/lib" />
</list> </list>
</value> </value>
</entry> </entry>
...@@ -121,7 +118,6 @@ ...@@ -121,7 +118,6 @@
<value> <value>
<list> <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-2.0.0/lib" />
<option value="$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/stream_channel-1.6.8/lib" />
</list> </list>
</value> </value>
</entry> </entry>
...@@ -143,7 +139,6 @@ ...@@ -143,7 +139,6 @@
<value> <value>
<list> <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.4/lib" />
<option value="$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.2/lib" />
</list> </list>
</value> </value>
</entry> </entry>
...@@ -164,27 +159,22 @@ ...@@ -164,27 +159,22 @@
</option> </option>
</properties> </properties>
<CLASSES> <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/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/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/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/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/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/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/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-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/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/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/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/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/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/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/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/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/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" /> <root url="file://$USER_HOME$/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/vector_math-2.0.8/lib" />
......
<component name="libraryTable"> <component name="libraryTable">
<library name="Flutter Plugins" type="FlutterPluginsLibraryType"> <library name="Flutter Plugins" type="FlutterPluginsLibraryType">
<CLASSES> <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> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES /> <SOURCES />
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="AndroidLogFilters"> <component name="AndroidLogFilters">
<option name="TOOL_WINDOW_CUSTOM_FILTER" value="fb" />
<option name="TOOL_WINDOW_CONFIGURED_FILTER" value="No Filters" /> <option name="TOOL_WINDOW_CONFIGURED_FILTER" value="No Filters" />
</component> </component>
<component name="CMakeSettings"> <component name="CMakeSettings">
...@@ -9,15 +10,7 @@ ...@@ -9,15 +10,7 @@
</configurations> </configurations>
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="27574137-5472-4670-9669-d8e092348fe1" name="Default" comment=""> <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>
<ignored path="$PROJECT_DIR$/.dart_tool/" /> <ignored path="$PROJECT_DIR$/.dart_tool/" />
<ignored path="$PROJECT_DIR$/.idea/" /> <ignored path="$PROJECT_DIR$/.idea/" />
<ignored path="$PROJECT_DIR$/.pub/" /> <ignored path="$PROJECT_DIR$/.pub/" />
...@@ -69,6 +62,10 @@ ...@@ -69,6 +62,10 @@
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="98"> <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" /> <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> </state>
</provider> </provider>
</entry> </entry>
...@@ -96,6 +93,7 @@ ...@@ -96,6 +93,7 @@
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes> <panes>
<pane id="Scope" />
<pane id="AndroidView" /> <pane id="AndroidView" />
<pane id="ProjectPane"> <pane id="ProjectPane">
<subPane> <subPane>
...@@ -125,7 +123,6 @@ ...@@ -125,7 +123,6 @@
</subPane> </subPane>
<option name="show-excluded-files" value="false" /> <option name="show-excluded-files" value="false" />
</pane> </pane>
<pane id="Scope" />
<pane id="PackagesPane" /> <pane id="PackagesPane" />
</panes> </panes>
</component> </component>
...@@ -250,6 +247,44 @@ ...@@ -250,6 +247,44 @@
<option name="myLimit" value="2678400000" /> <option name="myLimit" value="2678400000" />
</component> </component>
<component name="editorHistoryManager"> <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"> <entry file="file://$PROJECT_DIR$/test/screenshot_test.dart">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135"> <state relative-caret-position="135">
...@@ -512,6 +547,10 @@ ...@@ -512,6 +547,10 @@
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="98"> <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" /> <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> </state>
</provider> </provider>
</entry> </entry>
......
## [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 ## [0.1.0] - 09/05/2019
* changed path_provider version to ^1.1.0 * changed path_provider version to ^1.1.0
......
...@@ -61,20 +61,21 @@ Example: ...@@ -61,20 +61,21 @@ Example:
), ),
body: Container( body: Container(
child: new Center( child: new Center(
child: new Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Screenshot( //Screenshot Widget Screenshot(
controller: screenshotController, //asign Controller controller: screenshotController,
//wrap the widgets that you want to capture as image child: Column(
child: <Widget>[ children: <Widget>[
Text( Text(
'You have pushed the button this many times:' + 'You have pushed the button this many times:' +
_counter.toString(), _counter.toString(),
), ),
FlutterLogo(), FlutterLogo(),
], ],
), ),
),
_imageFile != null ? Image.file(_imageFile) : Container(), _imageFile != null ? Image.file(_imageFile) : Container(),
], ],
), ),
...@@ -84,18 +85,23 @@ Example: ...@@ -84,18 +85,23 @@ Example:
onPressed: () { onPressed: () {
_incrementCounter(); _incrementCounter();
_imageFile = null; _imageFile = null;
screenshotController.capture().then((File image) { screenshotController
.capture()
.then((File image) async {
//print("Capture Done");
setState(() { setState(() {
_imageFile = image; _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); print(onError);
}); });
}, },
tooltip: 'Increment', tooltip: 'Increment',
child: Icon(Icons.add), child: Icon(Icons.add),
), ), // This trailing comma makes auto-formatting nicer for build methods.
); );
} }
``` ```
...@@ -114,6 +120,10 @@ screenshotController.capture( ...@@ -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: ## Note:
Captured image may look pixelated. You can overcome this issue by setting value for **pixelRatio** Captured image may look pixelated. You can overcome this issue by setting value for **pixelRatio**
......
...@@ -33,6 +33,7 @@ def parse_KV_file(file, separator='=') ...@@ -33,6 +33,7 @@ def parse_KV_file(file, separator='=')
end end
target 'Runner' do target 'Runner' do
use_frameworks!
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines. # referring to absolute paths on developers' machines.
system('rm -rf .symlinks') system('rm -rf .symlinks')
...@@ -63,6 +64,7 @@ end ...@@ -63,6 +64,7 @@ end
post_install do |installer| post_install do |installer|
installer.pods_project.targets.each do |target| installer.pods_project.targets.each do |target|
target.build_configurations.each do |config| target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '4.2'
config.build_settings['ENABLE_BITCODE'] = 'NO' config.build_settings['ENABLE_BITCODE'] = 'NO'
end end
end end
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 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 */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; }; 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>"; }; 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>"; }; 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>"; }; 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>"; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
...@@ -55,6 +54,7 @@ ...@@ -55,6 +54,7 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 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>"; }; 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>"; }; 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 */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
files = ( files = (
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
3B80C3941E831B6300D905FE /* App.framework in Frameworks */, 3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
FA535D5D71EC7D63F66FE7B4 /* libPods-Runner.a in Frameworks */, A933A441C6953B1715F82792 /* Pods_Runner.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
92179A0594A73D07322FD9B6 /* Frameworks */ = { 92179A0594A73D07322FD9B6 /* Frameworks */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
345327055FDFC8D549E0BDD0 /* libPods-Runner.a */, FF0A07070FEC091E88E0B925 /* Pods_Runner.framework */,
); );
name = Frameworks; name = Frameworks;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -237,10 +237,14 @@ ...@@ -237,10 +237,14 @@
inputPaths = ( inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", "${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"; name = "[CP] Embed Pods Frameworks";
outputPaths = ( outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", "${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; runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh; shellPath = /bin/sh;
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
<string>LaunchScreen</string> <string>LaunchScreen</string>
<key>UIMainStoryboardFile</key> <key>UIMainStoryboardFile</key>
<string>Main</string> <string>Main</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Save Photos to Folder</string>
<key>UISupportedInterfaceOrientations</key> <key>UISupportedInterfaceOrientations</key>
<array> <array>
<string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortrait</string>
......
import 'dart:io'; import 'dart:io';
import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:screenshot/screenshot.dart'; import 'package:screenshot/screenshot.dart';
import 'package:image_gallery_saver/image_gallery_saver.dart';
void main() => runApp(MyApp()); void main() => runApp(MyApp());
...@@ -86,20 +88,21 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -86,20 +88,21 @@ class _MyHomePageState extends State<MyHomePage> {
), ),
body: Container( body: Container(
child: new Center( child: new Center(
child: new Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Screenshot( Screenshot(
controller: screenshotController, controller: screenshotController,
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Text( Text(
'You have pushed the button this many times:' + 'You have pushed the button this many times:' +
_counter.toString(), _counter.toString(),
), ),
FlutterLogo(), FlutterLogo(),
], ],
)), ),
),
_imageFile != null ? Image.file(_imageFile) : Container(), _imageFile != null ? Image.file(_imageFile) : Container(),
], ],
), ),
...@@ -109,11 +112,16 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -109,11 +112,16 @@ class _MyHomePageState extends State<MyHomePage> {
onPressed: () { onPressed: () {
_incrementCounter(); _incrementCounter();
_imageFile = null; _imageFile = null;
screenshotController.capture().then((File image) { screenshotController
.capture(delay: Duration(milliseconds: 10))
.then((File image) async {
//print("Capture Done"); //print("Capture Done");
setState(() { setState(() {
_imageFile = image; _imageFile = image;
}); });
final result =
await ImageGallerySaver.save(image.readAsBytesSync());
print("File Saved to Gallery");
}).catchError((onError) { }).catchError((onError) {
print(onError); print(onError);
}); });
...@@ -123,4 +131,9 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -123,4 +131,9 @@ class _MyHomePageState extends State<MyHomePage> {
), // This trailing comma makes auto-formatting nicer for build methods. ), // 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");
}
} }
...@@ -13,6 +13,7 @@ environment: ...@@ -13,6 +13,7 @@ environment:
sdk: ">=2.1.0 <3.0.0" sdk: ">=2.1.0 <3.0.0"
dependencies: dependencies:
image_gallery_saver: ^1.1.0
screenshot: screenshot:
path: ../ path: ../
flutter: flutter:
......
...@@ -14,28 +14,33 @@ class ScreenshotController { ...@@ -14,28 +14,33 @@ class ScreenshotController {
ScreenshotController() { ScreenshotController() {
_containerKey = GlobalKey(); _containerKey = GlobalKey();
} }
Future<File> capture({ Future<File> capture({
String path = "", String path = "",
double pixelRatio: 1, double pixelRatio: 1,
}) async { Duration delay: const Duration(milliseconds: 20)
try { }) {
RenderRepaintBoundary boundary = //DElay is required. See Issue https://github.com/flutter/flutter/issues/22308
this._containerKey.currentContext.findRenderObject(); return new Future.delayed(delay, () async {
ui.Image image = await boundary.toImage(pixelRatio: pixelRatio); try {
ByteData byteData = RenderRepaintBoundary boundary =
await image.toByteData(format: ui.ImageByteFormat.png); this._containerKey.currentContext.findRenderObject();
Uint8List pngBytes = byteData.buffer.asUint8List(); ui.Image image = await boundary.toImage(pixelRatio: pixelRatio);
if (path == "") { ByteData byteData =
final directory = (await getApplicationDocumentsDirectory()).path; await image.toByteData(format: ui.ImageByteFormat.png);
String fileName = DateTime.now().toIso8601String(); Uint8List pngBytes = byteData.buffer.asUint8List();
path = '$directory/$fileName.png'; 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);
}
} }
} }
......
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: 0.1.0 version: 0.1.1
author: Sachin Ganesh <sachinganesh@outlook.com> author: Sachin Ganesh <sachinganesh@outlook.com>
homepage: https://github.com/SachinGanesh/screenshot homepage: https://github.com/SachinGanesh/screenshot
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论