access_control 0.9.0 copy "access_control: ^0.9.0" to clipboard
access_control: ^0.9.0 copied to clipboard

Check access control via permissions.

example/lib/main.dart

import 'dart:async';

import 'package:access_control/access_control.dart';
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) => const MaterialApp(home: DemoPage());
}

class DemoPage extends StatefulWidget {
  const DemoPage({Key? key}) : super(key: key);

  @override
  State<DemoPage> createState() => _DemoPageState();
}

class DeveloperPermission extends PermissionInterface {
  final bool developer;

  DeveloperPermission(this.developer);

  @override
  FutureOr<bool> request(BuildContext context) {
    return developer;
  }
}

class _DemoPageState extends State<DemoPage> {
  var developer = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Access control')),
      body: Center(
        child: AccessControl.single(
          child: const Text('Developer workspace'),
          denied: const Text('Access denied'),
          permission: DeveloperPermission(developer),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(
          developer ? Icons.person_outline : Icons.bug_report_outlined,
        ),
        onPressed: () => setState(() => developer = !developer),
      ),
    );
  }
}
0
likes
140
pub points
27%
popularity

Publisher

unverified uploader

Check access control via permissions.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on access_control