I imported math.
import 'dart:math'; But how can I call "PI" constant?
This is not working.
math.pi / 12.0 3 Answers
you should import 'dart:math' as math; instead of just import 'dart:math';
because when you use the as keyword you provide the imported library a name so you can reference it anywhere in your file
As an alternative to the accepted answer, you can keep importing without a prefix, and reference pi as just pi:
import "dart:math" show pi; main() { print(pi / 12); } This works just as well as prefixing. It's a matter of taste which one you prefer.
0First import 'dart:math'; then use pi/12.0 instead of it should work fine.