본문으로 바로가기

 

 

dart:math library - Dart API

dart:math library Mathematical constants and functions, plus a random number generator. To use this library in your code: import 'dart:math'; Classes MutableRectangle A class for representing two-dimensional axis-aligned rectangles with mutable properties.

api.flutter.dev

 

import 'dart:math';

 

import한 후에 사용할 수 있는 상수와 함수는 다음과 같다.

 

Constants

e → const doubleBase of the natural logarithms. [...]

2.718281828459045

ln2 → const doubleNatural logarithm of 2. [...]

0.6931471805599453

ln10 → const doubleNatural logarithm of 10. [...]

2.302585092994046

log2e → const doubleBase-2 logarithm of e.

1.4426950408889634

log10e → const doubleBase-10 logarithm of e.

0.4342944819032518

pi → const doubleThe PI constant.

3.1415926535897932

sqrt1_2 → const doubleSquare root of 1/2.

0.7071067811865476

sqrt2 → const doubleSquare root of 2.

1.4142135623730951

 

 

Functions

acos(num x)  doubleConverts x to a double and returns its arc cosine in radians. [...]asin(num x)  doubleConverts x to a double and returns its arc sine in radians. [...]atan(num x)  doubleConverts x to a double and returns its arc tangent in radians. [...]

 

 

 

그런데 우리가 주로 관심있어하는 건 클래스이다

 

Classes

MutableRectangle<T extends num>A class for representing two-dimensional axis-aligned rectangles with mutable properties.

Point<T extends num>A utility class for representing two-dimensional positions.

RandomA generator of random bool, int, or double values. 

Rectangle<T extends num>A class for representing two-dimensional rectangles whose properties are immutable.

 

 

여기서 Random을 자주 쓴다. 필자는 다음과 Random의 메서드인 nextInt를 써서 0~5까지의 값을 랜덤하게 받고 +1을 하여서 1~6 값을 랜덤하게 출력하도록 만들었다.

DiceNumber = Random().nextInt(6) + 1;

darren, dev blog
블로그 이미지 DarrenKwonDev 님의 블로그
VISITOR 오늘 / 전체