1. Static 변수 static 멤버는 인스턴스에 귀속되지 않고 클래스에 귀속된다. (1) static 변수란 static 변수로 선언한 경우 인스턴스화를 하지 않고 클래스명으로 접근해서 사용할 수 있게 된다.
Person 클래스에 static 변수(country)와 final 상수(name)를 선언한다. 그리고 introduce() 메서드 정의하여 country와 name을 출력한다. class Person{ static String?
country; final String name; Person(this.name); void introduce(){ print('${this.name} [${country}]'); } } (2) 일반 변수와 static 변수 차이점 메인 함수에서 Person 객체를 하나 생성하고 introduce() 메서드를 호출한다. 생성자 함수를 통해 name의 값을 할당하였지만, country는 할당하지 않았다.
그리고 static 변수인 country는 ...
#
다트언어
#
Flutter
#
Static
#
Static변수
#
Static함수
#
다트
#
다트문법
#
플러터
원문 링크 : Dart 기본 문법 7: Static