static
-
[Dart] Dart에서의 static, const와의 차이점?Flutter 2023. 11. 1. 16:56
static static은 class 내에 귀속되어 고정되는 변수나 함수를 선언할 때 사용. 서로 다른 여러개의 인스턴스를 생성해도 static으로 지정한 값은 공유되어 참조한다. static을 사용한 변수는 내부에서도 this. 을 붙이지 않는다. static 키워드를 사용하여 생선한 method는 인스턴스를 생성하지 않고 직접 호출할 수 있다. = 좀 더 편리하게 사용하기 위해 사용 const class와는 상관없다. cosnt는 상수를 정의할 때 사용되고 런타임 때 변경 불가능하다. = 코드의 안정성을 위해 사용