Dart/Flutter - Converting Radian To Degree & Vice Versa

This tutorial shows how to to convert radian to degree and vice versa in Dart which also works in Flutter.

Below is the equation for conversion between those two measurement units.

360°=2π radians

which can be written as

1° = π/180°

1° equals to 0.0174533 radians, while 1 radians equals to 57.2958°

Even though Dart doesn't provide the methods for converting between radian and degree out of the box, there are packages providing methods for that purpose if you don't want to create your own method.

Converting Radian to Degree & Vice Versa Using vector_math

vector_math is a library from Google Developers that provides the functionality to do the conversions.

Adding Dependencies

First, you need to add the following dependency to the dependencies section of your pubspec.yaml.

    vector_math: any

Then you need to import the library on the file you want to invoke the methods.

  import 'package:vector_math/vector_math.dart'

Converting Radian to Degree

For converting radian to degree, use degrees method.

  degrees(0); // 0.0
  degrees(1); // 57.29577951308232

Converting Degree to Radian

For converting degree to radian, use radians method.

  radians(0); // 0.0
  radians(57.29577951308232); // 1.0
  radians(90); // 1.5707963267948966
  radians(360); // 6.283185307179586xx


That's how to perform conversion between those two measurement units.