Skip to content
New issue

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

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

Already on GitHub? # to your account

removed permission_handler dependency #59

Merged
merged 1 commit into from
Sep 30, 2022
Merged
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
23 changes: 1 addition & 22 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
permission_handler:
dependency: transitive
description:
name: permission_handler
url: "https://pub.dartlang.org"
source: hosted
version: "8.3.0"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "3.7.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
screenshot_callback:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -172,4 +151,4 @@ packages:
version: "2.1.2"
sdks:
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.5.0"
flutter: ">=2.2.0"
20 changes: 1 addition & 19 deletions lib/screenshot_callback.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import 'dart:io';
import 'dart:async';

import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:permission_handler/permission_handler.dart';

class ScreenshotCallback {
static const MethodChannel _channel =
Expand All @@ -12,23 +10,12 @@ class ScreenshotCallback {
/// Functions to execute when callback fired.
List<VoidCallback> onCallbacks = <VoidCallback>[];

/// If `true`, the user will be asked to grant storage permissions when
/// callback is added.
///
/// Defaults to `true`.
bool requestPermissions;

ScreenshotCallback({
this.requestPermissions = true,
}) {
ScreenshotCallback() {
initialize();
}

/// Initializes screenshot callback plugin.
Future<void> initialize() async {
if (Platform.isAndroid && requestPermissions) {
await checkPermission();
}
_channel.setMethodCallHandler(_handleMethod);
await _channel.invokeMethod('initialize');
}
Expand All @@ -52,9 +39,4 @@ class ScreenshotCallback {

/// Remove callback listener.
Future<void> dispose() async => await _channel.invokeMethod('dispose');

/// Checks if user has granted permissions for storage.
///
/// If permission is not granted, it'll be requested.
Future<void> checkPermission() async => await Permission.storage.request();
}
23 changes: 1 addition & 22 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -88,27 +88,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
permission_handler:
dependency: "direct main"
description:
name: permission_handler
url: "https://pub.dartlang.org"
source: hosted
version: "8.3.0"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "3.7.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -165,4 +144,4 @@ packages:
version: "2.1.2"
sdks:
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.5.0"
flutter: ">=2.2.0"
1 change: 0 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ environment:
dependencies:
flutter:
sdk: flutter
permission_handler: ^8.1.2

dev_dependencies:
flutter_test:
Expand Down