btrautmann / blackbird

A simple, type-safe boolean logic package for dart.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Blackbird

pub package CI codecov

A boolean logic library for Dart and Flutter, allowing you to build trees of conditions and evaluate them.

Purpose

While there is no limit to what you can/should do with blackbird, it's aimed at building flexible query UIs for your applications.

Example

Design

Blackbird is designed to provide the building blocks for building condition trees (blackbird is named after Blackbird State Forest in Delaware, US.). Out of the box, it provides the Condition, NestedCondition, TestCondition, and Test classes. You can use these to build complex trees of conditions and evaluate them.

Example usage

Check out the example for a simple example.

final condition = Or(
  [
    IsTrue(StartsWithLowerCase()),
    IsTrue(ContainsString('One')),
  ],
);

expect(condition.evaluate('hello'), isTrue);
expect(condition.evaluate('On'), isFalse);

Features

  • Type-safe: The entire condition tree is typed to your type T.
  • Extensible: Define Test objects according to your domain.
  • Readable: The API is designed to be readable and expressive.

Installation

dart pub add blackbird

About

A simple, type-safe boolean logic package for dart.

License:MIT License


Languages

Language:Dart 100.0%