cassowary
0.4.3, released 3 years ago by google.dev
Implementation of the Cassowary constraint solving algorithm in Dart.
WASM-ready
What it does
Provides a constraint solver that accepts linear equations and updates member variables to satisfy layout constraints. Makes specific affordances for the needs of Flutter.
AI-written summary of version 0.4.3, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to solve linear equality and inequality constraints for layout or positioning.
- You are implementing custom layout algorithms that require constraint-based layout systems like Cassowary.
Skip it when
- You are building standard UIs that can rely on Flutter's built-in layout widgets.
- You need a high-level state management or dependency injection library.
Strengths
- Direct Dart implementation of the Cassowary constraint solving algorithm.
- Tailored for the needs of Flutter.
Weaknesses
- Low-level library requiring manual setup of variables, expressions, and solvers.
- Limited documentation outside of basic README usage examples.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
No special dependencies or native steps required.
var widthAtLeast100 = right - left >= cm(100.0);
var edgesPositive = (left >= cm(0.0))..priority = Priority.weak;
solver
..addConstraints([widthAtLeast100, edgesPositive])
..flushUpdates();Works with
Packages commonly used together with cassowary: ones it builds on, ones built on it, and its own family.