access_warrant 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 61

Access Warrant #

This package provides a way to control access to a specific widget subtree with a conception called hereinafter “warrant check”.

Usage #

To use this package, add access_warrant as a dependency in your pubspec.yaml file.

Example #

Import the library.

import 'package:access_warrant/access_warrant.dart';

Then use it in any part of your widget tree just like an ordinary widget with builder method:

  // Provide a [validBuilder] to build a view of restricted access.
  validBuilder: (context) => Text('A widget you can not see until access rights confirmed.'),

  // Provide a [check] callback to verify access rights to the [validBuilder] result.
  check: () => {
    // Procedure of the check is literally any business logic that approves or denies
    // access rights to a specific part of the application. Returns `true` if access is
    // granted and `false` otherwise.

  // Provide a [wrongBuilder] to build a view for case if warrant check has failed.
  // This widget can then handle authentication or other procedure of getting valid warrant
  // to pass the check and access the restricted area like so:
  // `AccessWarrant.grantAccess(context)`.
  wrongBuilder: (context) => Text('Show this if the warrant is wrong.'),

Example of making your warrant valid from a page built by [wrongBuilder]:

  validBuilder: (context) => Text('Can not see this until you are authorized.'),
  wrongBuilder: (_) => RaisedButton(
    child: Text('Click me to get authorized!'),
    // [AccessWarrant.check] is called again on the new route so the warrant state should be
    // persisted in any appropriate way between the two routes to make AccessWarrant behaviour change.
    onPressed: () => AccessWarrant.grantAccess(context),
  // Return `false` to show the result of the [wrongBuilder] first.
  check: () => false,

Currently this package is developed for material applications. Other support will be added up to the 0.1.0 release.

0.0.3 #

  • Fix for showing valid builder result before navigation animation after access been granted.

0.0.2 #

  • Update code to satisfy breaking changes in Flutter 1.17.
  • Improve README and comments in code.
  • Add an example.

0.0.1 #

  • Initial release for material applications.


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

// In this example AccessWarrant is used to guard 'treasury-door' route against
// unauthorized access. After `grantAccess` is called a copy of the route gets pushed
// on top of the stack replacing the old route.

void main() {

// We store the treasury's state in variable to make this example brief.
bool treasuryIsOpened = false;

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Dwarves treasury',
      initialRoute: 'treasury-door',
      routes: {
        'treasury-door': (context) => Scaffold(
              body: AccessWarrant(
                wrongBuilder: (context) => Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 24),
                  child: Column(
                    children: <Widget>[
                      Text('You shall not pass without a key!'),
                      SizedBox(height: 20),
                        child: Text(
                          'Knock-knock!\nHello, please let me in, I\'ve brought some cookies :)',
                        padding: const EdgeInsets.all(12),
                        onPressed: () {
                          treasuryIsOpened = true;
                validBuilder: (_) => Center(
                  child: Text('Come in, you are welcome!'),
                check: () => treasuryIsOpened,

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  access_warrant: ^0.0.3

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:access_warrant/access_warrant.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart


  • access_warrant that is a package requiring null.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies