blackbird 0.0.4 copy "blackbird: ^0.0.4" to clipboard
blackbird: ^0.0.4 copied to clipboard

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

example/main.dart

import 'package:blackbird/blackbird.dart';

sealed class StringTest extends Test<String> {}

class ContainsString extends StringTest {
  ContainsString(this.value);
  final String value;

  @override
  bool call(String t) {
    return t.contains(value);
  }

  @override
  List<Object?> get props => [value];
}

class StartsWithLowerCase extends StringTest {
  StartsWithLowerCase();

  @override
  bool call(String t) {
    if (t.isEmpty) return false;
    final test = t.substring(0, 1);
    final regex = RegExp(r'^[a-z]$');
    return regex.hasMatch(test);
  }

  @override
  List<Object?> get props => [];
}

void main() {
  final condition = And(
    [
      IsTrue(StartsWithLowerCase()),
      IsTrue(ContainsString('One')),
    ],
  );

  print(condition.evaluate('payeeOne')); // true
  print(condition.evaluate('PayeeOne')); // false
}
0
likes
160
points
42
downloads

Publisher

unverified uploader

Weekly Downloads

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

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

collection, equatable, uuid

More

Packages that depend on blackbird