Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filename fix, example project updates #183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 30
compileSdkVersion 31

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand Down
1 change: 1 addition & 0 deletions example/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
3 changes: 2 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
FlutterApplication and put your custom class here. -->

<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


<application
android:name="io.flutter.app.FlutterApplication"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:label="gallery_saver_example">
<activity
Expand Down
78 changes: 45 additions & 33 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'dart:async';
import 'dart:io';
import 'dart:typed_data';
import 'dart:ui' as ui;

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:gallery_saver/gallery_saver.dart';
import 'package:image_picker/image_picker.dart';
import 'package:path_provider/path_provider.dart';
Expand Down Expand Up @@ -45,9 +45,13 @@ class _MyAppState extends State<MyApp> {
backgroundColor: MaterialStateProperty.all(Colors.blue),
),
onPressed: _takePhoto,
child: Text(firstButtonText,
style: TextStyle(
fontSize: textSize, color: Colors.white)),
child: Text(
firstButtonText,
style: TextStyle(
fontSize: textSize,
color: Colors.white,
),
),
),
),
),
Expand All @@ -61,9 +65,13 @@ class _MyAppState extends State<MyApp> {
backgroundColor: MaterialStateProperty.all(Colors.white),
),
onPressed: _recordVideo,
child: Text(secondButtonText,
style: TextStyle(
fontSize: textSize, color: Colors.blueGrey)),
child: Text(
secondButtonText,
style: TextStyle(
fontSize: textSize,
color: Colors.blueGrey,
),
),
),
)),
flex: 1,
Expand All @@ -76,39 +84,36 @@ class _MyAppState extends State<MyApp> {
}

void _takePhoto() async {
ImagePicker()
.getImage(source: ImageSource.camera)
.then((PickedFile recordedImage) {
if (recordedImage != null && recordedImage.path != null) {
final recordedImage =
await ImagePicker().pickImage(source: ImageSource.camera);
if (recordedImage != null && recordedImage.path != null) {
setState(() {
firstButtonText = 'saving in progress...';
});
GallerySaver.saveImage(recordedImage.path, albumName: albumName)
.then((bool success) {
setState(() {
firstButtonText = 'saving in progress...';
});
GallerySaver.saveImage(recordedImage.path, albumName: albumName)
.then((bool success) {
setState(() {
firstButtonText = 'image saved!';
});
firstButtonText = 'image saved!';
});
}
});
});
}
}

void _recordVideo() async {
ImagePicker()
.getVideo(source: ImageSource.camera)
.then((PickedFile recordedVideo) {
if (recordedVideo != null && recordedVideo.path != null) {
final recordedVideo =
await ImagePicker().pickVideo(source: ImageSource.camera);

if (recordedVideo != null && recordedVideo.path != null) {
setState(() {
secondButtonText = 'saving in progress...';
});
GallerySaver.saveVideo(recordedVideo.path, albumName: albumName)
.then((bool success) {
setState(() {
secondButtonText = 'saving in progress...';
secondButtonText = 'video saved!';
});
GallerySaver.saveVideo(recordedVideo.path, albumName: albumName)
.then((bool success) {
setState(() {
secondButtonText = 'video saved!';
});
});
}
});
});
}
}

// ignore: unused_element
Expand Down Expand Up @@ -173,6 +178,13 @@ class _ScreenshotWidgetState extends State<ScreenshotWidget> {
//extract bytes
final RenderRepaintBoundary boundary =
_globalKey.currentContext.findRenderObject();

// if it needs repaint, we paint it.
if (boundary.debugNeedsPaint) {
Timer(Duration(seconds: 1), () => _saveScreenshot());
return null;
}

final ui.Image image = await boundary.toImage(pixelRatio: 3.0);
final ByteData byteData =
await image.toByteData(format: ui.ImageByteFormat.png);
Expand Down
80 changes: 47 additions & 33 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.8.1"
version: "2.8.2"
boolean_selector:
dependency: transitive
description:
Expand All @@ -21,7 +21,7 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0"
charcode:
dependency: transitive
description:
Expand Down Expand Up @@ -49,7 +49,7 @@ packages:
name: cross_file
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.1+5"
version: "0.3.2"
fake_async:
dependency: transitive
description:
Expand All @@ -63,14 +63,14 @@ packages:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.1.2"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.0"
version: "6.1.2"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -82,7 +82,7 @@ packages:
name: flutter_plugin_android_lifecycle
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "2.0.5"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -99,14 +99,14 @@ packages:
path: ".."
relative: true
source: path
version: "2.1.3"
version: "2.3.2"
http:
dependency: "direct main"
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.13.3"
version: "0.13.4"
http_parser:
dependency: transitive
description:
Expand All @@ -120,21 +120,21 @@ packages:
name: image_picker
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.4+2"
version: "0.8.4+10"
image_picker_for_web:
dependency: transitive
description:
name: image_picker_for_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
version: "2.1.6"
image_picker_platform_interface:
dependency: transitive
description:
name: image_picker_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.1"
version: "2.4.4"
js:
dependency: transitive
description:
Expand All @@ -148,7 +148,14 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10"
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
meta:
dependency: transitive
description:
Expand All @@ -169,63 +176,70 @@ packages:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.0.9"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.12"
path_provider_ios:
dependency: transitive
description:
name: path_provider_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.5"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.5"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
version: "2.0.3"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.0"
version: "2.0.5"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.1.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.2"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
version: "4.2.4"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -272,7 +286,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.2"
version: "0.4.8"
typed_data:
dependency: transitive
description:
Expand All @@ -286,21 +300,21 @@ packages:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.1.1"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
version: "2.4.1"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
version: "0.2.0+1"
sdks:
dart: ">=2.14.0 <3.0.0"
flutter: ">=2.5.0"
dart: ">=2.15.0 <3.0.0"
flutter: ">=2.8.0"
Loading