- [Flutter] 두점(..) 세점(...) 사용법 목차
dart언어에서 두점(..) 오퍼레이터는 생성된 인스턴스내의 멤버 또는 멤버함수를 직접 엑세스하는 오퍼레이터이다
animation = CurveAnimation( <- animation 인스턴스 생성
parent: controller,
curve: Curves.easeInOutCubic,
).drive(Tween(begin: 0, end: 2));
animation.addListener(( ) { <- 인스턴스의 멤버 함수 선언
print('animation listener');
});
animation.addStatusListener((status) { <- 인스턴스의 멤버 함수 선언
print('animation status listened - $status');
});
위의 2개 멤버함수의 접근을 두점(..) 오퍼레이터를 사용하여 아래처럼 사용할 수 있다
animation = CurveAnimation(
parent: controller,
curve: Curves.easeInOutCubic,
).drive(Tween(begin: 0, end: 2))
..ddListener(( ) { <- animation 인스턴스의 메버함수를 인스턴스 선언하면서 함수를 바로 선언
print('animation listener');
})
..addStatusListener((status) { <- animation 인스턴스의 메버함수를 인스턴스 선언하면서 함수를 바로 선언
print('animation status listened - $status');
});
즉 생성된 인스턴스를 쓰고 멤버함수를 호출하는 것보다 간략하게 접근할 수 있다
참고영상: www.youtube.com/watch?v=4wTKcFr6Me4
세점(...) 오퍼레이터
선언된 List를 다른 List내에 포함시킬 경우에 사용한다.
static List<int> numbers = [6, 7, 8, 9, 10];
List<int> origin = [1, 2, 3, 4, 5, ...numbers];
또는
children: [1, 2, 3, 4, 5, ...numbers].map(number) {
이렇게도 사용할 수 있다
즉, ...numbers로 선언된 부분이 해당 List 값으로 채워진다
children: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(number) {
참고영상: www.youtube.com/watch?v=iG16Xdn1r94&t=22s
세점(...) 오퍼레이션의 또 다른 사용법
위와 비슷한거 같기도 하고 다른거 같기도 하고..
ListView에서 많이 사용하는 방법이다
....
body: ListView(
physics: BouncingScrollPhysics().
children: <widget>[
...LoadMemo( ) <- LoadMemo( ) 함수내의 모든 List를 반복적으로 출력
] //Widget
), //ListView
List<Widget> LoadMemo( ) {
List<Widget> memoList = [ ];
memoList.add(Container(color: Colors.purpleAccent, height: 100, ));
memoList.add(Container(color: Colors.redAccent, height: 100, ));
return memoList;
}
}
즐거운 시간되세요^^
'flutter' 카테고리의 다른 글
[Flutter]SQLite에 사용하는 toMap( ) List.generate(maps.length, (i)) (0) | 2020.10.25 |
---|---|
[Flutter] 위젯간 Data 전달하기(생성자 변수, 함수 포인터) (0) | 2020.10.25 |
flutter_form_builder 패키지 사용법 (0) | 2020.10.18 |
[Flutter]AppBar의 좌측 버튼 제거하기 (0) | 2020.10.11 |
[Flutter] MediaQuery 위젯 (0) | 2020.10.11 |