Constructor1 [Flutter] Class, constructor, property 아래와 같이 Person 클래스를 정의한다고 해 보자. class Person { // property double height; int age = 0; // constructor Person({double startingHeight}) { height = startingHeight; } // method void grow(int numberOfYears) { age = age + numberOfYears; } } Person 클래스는 double 타입의 height과 int 타입의 age를 property로 갖는다. (멤버 변수) 생성자를 선언할 때 {}, named parameter를 사용했는데, this keyword를 사용해 생성자를 선언할 때는 named parameter 적용이 optional.. 2021. 8. 15. 이전 1 다음