Your List have duplicate value. In my demo, add an extra index 1 to prove it work
For unique and index only , use indexWhere
For return qualified list use where , firstWhere, singleWhere
You can see DarPad result
code snippet
void main() {
List<Map> productList = [{"index":0,"productId":"5d9890c7773be00ab5b41701","qty":2}, {"index":0,"productId":"5d9890c7773be00ab5b41701","qty":3}, {"index":1,"productId":"5d9890c7773be00ab5b41702","qty":23}];
int index = productList.indexWhere((prod) => prod["productId"]=='5d9890c7773be00ab5b41701' );
print(index);
var prodLists = productList.where((prod) => prod["productId"] == '5d9890c7773be00ab5b41701');
print('${prodLists}');
}
Output
0
({index: 0, productId: 5d9890c7773be00ab5b41701, qty: 2}, {index: 0, productId: 5d9890c7773be00ab5b41701, qty: 3})