boolean_selector 1.0.2

The boolean_selector package defines a simple and flexible syntax for boolean expressions. It can be used for filtering based on user-defined expressions. For example, the test package uses boolean selectors to allow users to define what platforms their tests support.

The boolean selector syntax is based on a simplified version of Dart's expression syntax. Selectors can contain identifiers, parentheses, and boolean operators, including ||, &&, !, and ? :. Any valid Dart identifier is allowed, and identifiers may also contain hyphens. For example, chrome, chrome || content-shell, and js || (vm && linux) are all valid boolean selectors.

A boolean selector is parsed from a string using new BooleanSelector.parse(), and evaluated against a set of variables using BooleanSelector.evaluate(). The variables may be supplied as a list of strings, or as a function that takes a variable name and returns its value. For example:

import 'package:boolean_selector/boolean_selector.dart';

void main(List<String> args) {
  var selector = new BooleanSelector.parse("(x && y) || z");
  print(selector.evaluate((variable) => args.contains(variable)));
}

Versioning

If this package adds new features to the boolean selector syntax, it will increment its major version number. This ensures that packages that expose the syntax to their users will be able to update their own minor versions, so their users can indicate that they rely on the new syntax.

1.0.2

  • Declare compatibility with string_scanner 1.0.0.

1.0.1

  • Fix all strong mode warnings.

1.0.0

  • Initial release.

1. Depend on it

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

dependencies:
  boolean_selector: "^1.0.2"

2. Install it

You can install packages from the command line:

$ pub get

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

3. Import it

Now in your Dart code, you can use:

import 'package:boolean_selector/boolean_selector.dart';

About

A flexible syntax for boolean expressions.

Author

Email misc@dartlang.org Dart Team

Homepage

github.com/dart-lang/boolean_selector

Documentation

www.dartdocs.org/documentation/boolean_selector/1.0.2/

Source code (hyperlinked)

www.crossdart.info/p/boolean_selector/1.0.2/

Uploader

nweiz@google.com

Share