Mathematical constants and functions, plus a random number generator.
To use this library in your code:
import 'dart:math';
Random is a generator of bool, int or double values.
var intValue = Random().nextInt(10); // Value is >= 0 and < 10. var doubleValue = Random().nextDouble(); // Value is >= 0.0 and < 1.0. var boolValue = Random().nextBool(); // true or false, with equal chance.
Point is a utility class for representing two-dimensional positions.
var leftTop = const Point(0, 0); var rightBottom = const Point(200, 400);
Rectangle is a class for representing two-dimensional axis-aligned rectangles whose properties are immutable.
Create a rectangle spanned by the points.
var leftTop = const Point(20, 50); var rightBottom = const Point(300, 600); var rectangle = Rectangle.fromPoints(leftTop, rightBottom); print(rectangle.left); // 20 print(rectangle.top); // 50 print(rectangle.right); // 300 print(rectangle.bottom); // 600
Create a rectangle spanned by (left, top) and (left+width, top+height).
var rectangle = const Rectangle(20, 50, 300, 600); print(rectangle.left); // 20 print(rectangle.top); // 50 print(rectangle.right); // 320 print(rectangle.bottom); // 650
MutableRectangle is a class for representing two-dimensional axis-aligned rectangles with mutable properties.
Create a mutable rectangle spanned by (left, top) and (left+width, top+height).
var rectangle = MutableRectangle(20, 50, 300, 600); print(rectangle); // Rectangle (20, 50) 300 x 600 print(rectangle.left); // 20 print(rectangle.top); // 50 print(rectangle.right); // 320 print(rectangle.bottom); // 650 // Change rectangle width and height. rectangle.width = 200; rectangle.height = 100; print(rectangle); // Rectangle (20, 50) 200 x 100 print(rectangle.left); // 20 print(rectangle.top); // 50 print(rectangle.right); // 220 print(rectangle.bottom); // 150
2.718281828459045 2.302585092994046 0.6931471805599453 0.4342944819032518 1.4426950408889634 3.1415926535897932 0.7071067811865476 1.4142135623730951 x to a double and returns its arc cosine in radians. x to a double and returns its arc sine in radians. x to a double and returns its arc tangent in radians. radians to a double and returns the cosine of the value. x to a double and returns the natural exponent, e, to the power x. x to a double and returns the natural logarithm of the value. x to the power of exponent. radians to a double and returns the sine of the value. x to a double and returns the positive square root of the value. radians to a double and returns the tangent of the value.
© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-math/dart-math-library.html