angles 1.2.1

Dart Angles #

Official Dart package

Say goodby to naming suffixes like ...deg or ...rad, manual angle conversions like x * rad2deg and the inevitable mess when mixing up multiple angle units in your code.

This library provides a single class named Angle, wrapping your angle variables in a far more readable way, whereas raw doubles aren't very expressive about how they store their values. One can create an angle from various units, including degrees, radians, gradians and turns.

// Various ways to define a half turn:
a0 = Angle.fromDegrees(180.0);
a1 = Angle.fromRadians(math.pi);
a2 = Angle.fromTurns(0.5);

a0.degrees; // = 180.0
a1.radians; // = 3.1415...
a2.turns;   // = 0.5

Trigonometic functions are defined on instances:

x = Angle.asin(0.3);
y = x.sin; // = 0.3

Angles are immutable by design, but there are operators like +, creating new angles:

// 270°:
x = Angle.halfTurn() + Angle.fromDegrees(90.0);


import 'package:angles/angles.dart';
import 'dart:math' as math;

main() {
  // Various ways to define a half turn:
  final x = Angle.fromDegrees(180.0);
  final y = Angle.fromRadians(math.pi);
  final z = Angle.fromTurns(0.5);
  x.degrees; // = 180.0
  x.radians; // = 3.1415...
  x.turns;   // = 0.5

  // One can use built-in trigonometric functions:
  final a = Angle.asin(0.3);
  print(a.sin); // = 0.3
  // Angles are immutable, but there are operators like +, creating new angles:
  final threeQuarterTurn = Angle.halfTurn() + Angle.fromDegrees(90.0);
  print(threeQuarterTurn); // 270°

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  angles: ^1.2.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:angles/angles.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Mar 30, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Format lib/src/angles_base.dart.

Run dartfmt to format lib/src/angles_base.dart.

Maintenance issues and suggestions

Provide a file named (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
meta ^1.0.0 1.1.8
Dev dependencies
test ^1.0.0