https://dart.dev/null-safety/faq#the-iterablefirstwhere-method-no-longer-accepts-orelse---null Import package:collection and use the extension method firstWhereOrNull instead of firstWhere.