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

outdated

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}');
}
10
likes
0
pub points
66%
popularity

Publisher

verified publishergoogle.dev

An implementation of the Cassowary constraint solving algorithm in Dart.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on cassowary