Importing and using a Library

The following example imports the built-in library dart: math. The snippet calls the sqrt() function from the math library. This function returns the square root of a number passed to it.

import ‘dart:math’; 

void main() { 

  print(“Square root of 36 is: ${sqrt(36)}”); 

}

Output

Square root of 36 is: 6.0

Leave a comment

Your email address will not be published. Required fields are marked *