Skip to content
pubscout

boolean_selector

2.1.2, released 2 years ago by tools.dart.dev

Parses and evaluates simplified Dart-like boolean expression strings.

WASM-readyQuiet but busy
$ flutter pub add boolean_selector
Source repository

What it does

Defines a flexible syntax for boolean expressions containing identifiers, parentheses, and operators like ||, &&, !, and ? :. It parses these expressions from strings into a BooleanSelector object and evaluates them against a set of variables supplied via a function.

AI-written summary of version 2.1.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to allow users or configuration files to define boolean expressions and filtering rules.
  • You want a syntax closely resembling Dart's expression language for boolean logic.

Skip it when

  • You only need standard boolean evaluations natively supported by Dart without parsing strings.
  • You need full general-purpose math or string expression evaluation beyond booleans.

Strengths

  • Provides a simple and flexible syntax based on Dart's expression syntax.
  • Supports identifiers with hyphens and standard boolean operators.

Weaknesses

  • Limited to boolean expressions only.
  • Not documented for complex macro or state management systems beyond evaluating string expressions.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
2
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)));
}

Alternatives

Packages that do the same job and could replace boolean_selector.

  • eval_ex

    Mathematical and boolean expression evaluator supporting arbitrary precision.

Works with

Packages commonly used together with boolean_selector: ones it builds on, ones built on it, and its own family.