boolean_selector

v2.1.2

A flexible syntax for boolean expressions, based on a simplified version of Dart's expression syntax.

Package archive: https://pubdev.letsnova.ru/api/archives/boolean_selector/2.1.2.tar.gz

Installdart pub add boolean_selector

Readme

Build Status Pub Package package publisher

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 BooleanSelector.parse(), and evaluated against a set of variables using BooleanSelector.evaluate(). The variables are supplied 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 = 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.

Changelog

2.1.2

  • Increase the SDK minimum to 3.1.0.
  • Move to dart-lang/tools monorepo.

2.1.1

  • Increase the SDK minimum to 2.17.0.
  • Populate the pubspec repository field.

2.1.0

  • Stable release for null safety.

2.0.0

  • Breaking: BooleanSelector.evaluate always takes a bool Function(String). For use cases previously passing a Set<String>, tear off the .contains method. For use cases passing an Iterable<String> it may be worthwhile to first use .toSet() before tearing off .contains.

1.0.5

  • Update package metadata & add example/ folder

1.0.4

  • Now requires Dart 2.

1.0.3

  • Work around an inference bug in the new common front-end.

1.0.2

  • Declare compatibility with string_scanner 1.0.0.

1.0.1

  • Fix all strong mode warnings.

1.0.0

  • Initial release.