본문 바로가기
Development Solutions/Flutter & Dart

[flutter] How to fix the error "'WhereIterable<Products>' is not a subtype of type 'List<Products>'"

by Dev Diary Hub 2022. 1. 25.
반응형

 

 

 

문제 상황

flutter 앱 실행 중에 아래와 같은 에러메시지가 표시되고 빌드에 실패합니다.

 

How to fix the error "'WhereIterable<Products>' is not a subtype of type 'List<Products>'"

 

 

 

 

 

해결 방법

아래와 같이 리스트로 변환하여 복사합니다.

 

  List<Products> filter(String title) {
    return products.where((element) => element.category == title).toList();
  }

 

 

 

 

https://www.google.com/search?q=Unhandled+Exception%3A+type+%27WhereIterable%3CStore%3E%27+is+not+a+subtype+of+type+%27List&rlz=1C1IBEF_koKR957KR957&oq=Unhandled+Exception%3A+type+%27WhereIterable%3CStore%3E%27+is+not+a+subtype+of+type+%27List&aqs=chrome..69i57.253j0j7&sourceid=chrome&ie=UTF-8 

 

Unhandled Exception: type 'WhereIterable<Store>' is not a subtype of type 'List - Google 검색

snapshot.data.documents.map ((document) { return new ListTile( title: new Text(document['name']), subtitle: new Text("Class"), ); }).toList()

www.google.com

 

반응형