Skip to content

Converted plugin to library #14

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

Merged
merged 1 commit into from
Aug 14, 2018
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,31 @@ dependencies:
``` dart
import 'package:permission_handler/permission_handler.dart';

Map<PermissionGroup, PermissionStatus> permissions = await PermissionHandler().requestPermissions(PermissionGroup.Contacts);
Map<PermissionGroup, PermissionStatus> permissions = await PermissionHandler.requestPermissions([PermissionGroup.contacts]);
```

### Checking permission

``` dart
import 'package:permission_handler/permission_handler.dart';

PermissionStatus permission = await PermissionHandler().checkPermissionStatus(PermissionGroup.Contacts);
PermissionStatus permission = await PermissionHandler.checkPermissionStatus(PermissionGroup.contacts);
```

### Open app settings

``` dart
import 'package:permission_handler/permission_handler.dart';

bool isOpened = await PermissionHandler().openAppSettings();
bool isOpened = await PermissionHandler.openAppSettings();
```

### Show a rationale for requesting permission (Android only)

``` dart
import 'package:permission_handler/permission_handler.dart';

bool isShown = await PermissionHandler().shouldShowRequestPermissionRationale(PermissionGroup.Contacts);
bool isShown = await PermissionHandler.shouldShowRequestPermissionRationale(PermissionGroup.contacts);
```

This will always return `false` on iOS.
Expand Down
1 change: 0 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:permission_handler/permission_enums.dart';
import 'package:permission_handler/permission_handler.dart';

void main() => runApp(new MyApp());
Expand Down
2 changes: 2 additions & 0 deletions lib/permission_enums.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
part of permission_handler;

/// Defines the state of a permission group
enum PermissionStatus {
/// Permission to access the requested feature is denied by the user.
Expand Down
8 changes: 6 additions & 2 deletions lib/permission_handler.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
library permission_handler;

import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:flutter/services.dart';
import 'package:permission_handler/permission_enums.dart';
import 'package:permission_handler/utils/codec.dart';

part 'package:permission_handler/permission_enums.dart';
part 'package:permission_handler/utils/codec.dart';

/// Provides a cross-platform (iOS, Android) API to request and check permissions.
class PermissionHandler {
Expand Down
4 changes: 1 addition & 3 deletions lib/utils/codec.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'dart:convert';

import 'package:permission_handler/permission_enums.dart';
part of permission_handler;

class Codec {
static PermissionStatus decodePermissionStatus(dynamic value) {
Expand Down