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
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.
Works with
Packages commonly used together with boolean_selector: ones it builds on, ones built on it, and its own family.
- source_spanboolean_selector depends on itStandard representation for source code locations, spans, and human-friendly error messages.
- string_scannerboolean_selector depends on itA class for parsing strings using a sequence of patterns.
- analyzerSame familyPerforms static analysis of Dart code for tool integration and embedding.
- yamlSame familyA Dart library for parsing YAML documents into Dart data structures.
- globSame familyA file and directory globbing library that supports Bash-style path matching and listing.
- ioSame familyUtilities for the Dart VM Runtime including ANSI colors, file copying, and exit code values.
- dart_styleSame familyProvides an API and CLI to format Dart source code automatically.
- source_mapsSame familyA Dart library to parse, build, and manipulate source map v3 files.