반응형
tolist
-
firstwhere(),where(), toList(), toSet(), any(), map()프로그래밍 공부 메모/flutter 2022. 6. 14. 18:53
1. where() 조건을 필터링 함수형 프로그래밍을 지원하고 함수들의 결과를 반복 가능한 타입으로 반환 var items = [1,2,3,4]; items.where((e) => e % 2 == 0).forEach(print); //2, 4 2. toList() 리스트 형태로 변환하여 반환함 final result = itmes.where((e) => e % 2 == 0).toList(); 3. toSet() 중복되는 테이터가 없는 set컬렉션으로 변환 final result = itmes.where((e) => e % 2 == 0).toSet().toList(); 4. any 특정 조건을 충족하는 요소가 있는지 없는지 검사 print(items.any((e) => e % 2 == 0)); 5. fir..