[Flutter] get and set
-
[Flutter] get and set웹 and 앱 프로그래밍/Flutter 2022. 12. 28. 21:09
Flutter에선 private로 선언 되어있어도(public선언이 없는 class) 같은 파일에만 있다면 값을 공유할수있다. 그러나 같은 파일에 없는 값에 접근할때는 get set을 사용한다. (C++같은 언어에서는 직접 함수를 만들어야하지만 Flutter에서는 간단하게 선언할수있다) int? set Get_Set_Number=> this._Get_Set_Number;//=>은 앞에 함수가 리턴할값(this._Get_Set_Number)을 의미 int? get Get_Set_Number(Value)=> this._Get_Set_Number= Value;//변수값(this._Get_Set_Number) 변경 (this란 클래스 자기자신을 의미)