i have a problem with my dart code when i add where function it gives me this error A value of type 'Iterable' can't be returned from the function '_recentTransactions' because it has a return type of 'List

  final List<Transactions> _transactionsList = [

  ];
  List<Transactions> get _recentTransactions{
    return _transactionsList.where((element) => {

    };
  }


Solution 1: PatrickMahomes

Try casting your return value as a List<Transactions>:

List<Transactions> get recentTransactions {
  return _transactionsList.where((element) {
    //...
  }) as List<Transactions>;
}


Solution 2: Ward Suleiman

Just call toList() it is in the Iterable class:

List<Transactions> get recentTransactions {
  return _transactionsList.where((element) {
    return true // or whatever;
  }).toList();
}