I use this getter to make a list:
List<CabModel> get cabs() => cabsList.value;
and works. But now I need to pass a parameter to filter a list. Something like
List<CabModel> get cabs(String value) => cabsList.value;
I know, I can't pass parameter in getters, but how do it?
The getter only sends back copy of data, but cannot make any changes/filter stuff. You'd have to create a function that takes in the required parameters and returns the required value.
If you also want to filter and overwrite the existing data, make a setter as well.
List FilteredList(...){
.../required filtering
return list
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.