A, batteries‑included utility package, that was built for Dart. It provides:
Documentation can be found here.
Add dartora to your project:
dart pub add dartora
Then import what you need:
import 'package:dartora/dartora.dart';
// or narrowly:
import 'package:dartora/collections.dart';
import 'package:dartora/search.dart';
import 'package:dartora/math.dart';
import 'package:dartora/util.dart';
We added many different types of collections in.
IterationConstruct<E>
, Iteration<E>
, IterationBase<E>
, IterationMap<K, V>
.IterationItem<E>
, IterationList<E>
, IterationHolder<E>
, IterationItemMap<K, V>
.IteratorBuild<E>
, IndexBaseIterator<E>
, HolderIterator<E>
.MultiViewList<E>
, LargeList<E>
, IterableItems<E>
.OrderedMap<K,V>
– insertion‑ordered map with stable key order.import 'package:dartora/collections.dart';
final omap = OrderedMap<String, int>(map: {});
omap['b'] = 2;
omap['a'] = 1;
// Keeps insertion order across keys & iteration
for (final k in omap.keys) {
print('$k → ${omap[k]}');
}
MultiViewList
and LargeList
help you present slices/views over large datasets without copying.
We added a way to build out simple search systems.
Searchable
, Tags
, Tag<E>
.Search
, SearchQuery
, QueryEngine
, QueryBuilder
, PatternItem
, SearchQueryComparison
, SearchItem
.import 'package:dartora/search.dart';
// Minimal Searchable using the factory
final items = [
Searchable.build(
id: '1', name: 'Red Apple', type: SearchableType.child,
title: 'Apple', description: 'A sweet red fruit',
tags: Tags([
Tag<bool>('red', true),
Tag<String>('category', 'fruit'),
]),
),
Searchable.build(
id: '2', name: 'Green Kale', type: SearchableType.child,
title: 'Kale', description: 'Leafy and bitter',
tags: Tags([
Tag<bool>('green', true),
Tag<String>('category', 'vegetable'),
]),
),
];
// Build a query from a human string
final search = Search.from('"sweet" -bitter #red app*');
final results = search.search(held: items);
for (final si in results) {
print('${si.item.title}: ${si.comparison.points.total}');
}
Default query syntax (via QueryEngine.defaultEngine
):
Token | Meaning | Notes |
---|---|---|
"..." |
Collector; marks a required phrase | e.g. "sweet fruit" must appear |
- |
Forbidden word/phrase | e.g. -bitter |
# |
Tag search | e.g. #red or #category |
* |
Wildcard | e.g. app* → apple , application , … |
\ |
Escape next special token | e.g. \#literal |
space | Splits terms | terms are scored individually |
The engine produces a SearchQuery
with optional, required, cannot and tag groups, and computes a SearchQueryComparison
with a Points
score. Use Search.validityCheck
/itemCheck
to filter invalid hits.
We added several new mathematical computations in.
round(...)
+ RoundMode
, root
, log
helpers, comparison
utilities.Points
(scoring), Matrix
, curves
, BaseRadix
, Points
collection helpers.import 'package:dartora/math.dart';
final a = round(2.34567, decimals: 2); // 2.35 (default: halfUp)
final b = round(2.5, mode: RoundMode.halfEven); // 2.0 → banker's rounding
final c = round(-3.5, mode: RoundMode.halfAwayFrom); // -4.0 → away from zero
Available modes (see RoundMode
): halfUp
, halfEven
, halfOdd
, halfAwayFrom
, halfToZero
, awayFrom
, alwaysToZero
.
This part of the package is really simple, it has the utilities that were built because of this package.
ModificationListener
, ModLevel
, ModificationAction
.BaseException
, TypeException
, KeyException
with helpful messages.For search, you can customize the parser by supplying your own QueryEngine(patternItems: [...])
.
final engine = QueryEngine(patternItems: const [
PatternItem.ignore, // \
PatternItem.hold, // "..."
PatternItem.space, // space
PatternItem.cannotHave, // -
PatternItem.tag, // #
PatternItem.wild, // *
]);
final query = SearchQuery.from('ice -hot #dessert', engine: engine);
RoundMode
is fully configurable: you can construct custom modes (even/odd/zero/away, thresholds, reversal, etc.).
const bankerTowardZero = RoundMode(
roundAt: 5,
reverse: false,
toEven: true,
toOdd: false,
toZero: true,
awayFromZero: false,
allowSubtract: false,
);
final v = round(12.55, decimals: 1, mode: bankerTowardZero);
Licensed under the Apache License, Version 2.0.