permission_asker 1.0.0+1 copy "permission_asker: ^1.0.0+1" to clipboard
permission_asker: ^1.0.0+1 copied to clipboard

A wrapper for permission_handler which lifts some of the boilerplate needed to handle permissions in our apps.

example/lib/main.dart

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Permission asker demo',
      home: Home(),
    );
  }
}

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Permission asker demo'),
      ),
      body: PermissionAskerBuilder(
        permissions: [
          Permission.location,
          Permission.camera,
        ],
        grantedBuilder: (context) => Center(
          child: Text('All permissions granted!'),
        ),
        notGrantedBuilder: (context, notGrantedPermissions) => Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Text('Not granted permissions:'),
              for (final p in notGrantedPermissions) Text(p.toString())
            ],
          ),
        ),
        notGrantedListener: (notGrantedPermissions) =>
            print('Not granted:\n$notGrantedPermissions'),
      ),
    );
  }
}
19
likes
130
points
7
downloads

Publisher

verified publishermagicleon94.dev

Weekly Downloads

A wrapper for permission_handler which lifts some of the boilerplate needed to handle permissions in our apps.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, pedantic, permission_handler

More

Packages that depend on permission_asker