cassowary 0.4.3 copy "cassowary: ^0.4.3" to clipboard
cassowary: ^0.4.3 copied to clipboard

An implementation of the Cassowary constraint solving algorithm in Dart.

example/main.dart

// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:cassowary/cassowary.dart';

void main() {
  final solver = Solver();
  final left = Param(10);
  final right = Param(20);
  final widthAtLeast100 = right - left >= cm(100);
  final edgesPositive = (left >= cm(0))..priority = Priority.weak;
  solver
    ..addConstraints([widthAtLeast100, edgesPositive])
    ..flushUpdates();

  print('left: ${left.value}, right: ${right.value}');

  final mid = Variable(15);
  // It appears that == isn't defined
  solver
    ..addConstraint((left + right).equals(Term(mid, 1) * cm(2)))
    ..addEditVariable(mid, Priority.strong)
    ..flushUpdates();

  print('left: ${left.value}, mid: ${mid.value}, right: ${right.value}');
}
9
likes
140
pub points
70%
popularity

Publisher

verified publishergoogle.dev

An implementation of the Cassowary constraint solving algorithm in Dart.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

BSD-3-Clause (LICENSE)

More

Packages that depend on cassowary