From 0c569cb5ea45146aaec48935fd857f34594e0539 Mon Sep 17 00:00:00 2001 From: "M. Hanif Shahy" <100494103+hanifshahy@users.noreply.github.com> Date: Tue, 2 Apr 2024 19:16:02 +0430 Subject: [PATCH] Update basics.md (#1276) In this example firstWhere() causes compile time error if null passed to its orElse named parameter in dart 3. I fix it by using firstWhereOrNull() with no orElse named parameter. --- content/en/docs/languages/dart/basics.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/content/en/docs/languages/dart/basics.md b/content/en/docs/languages/dart/basics.md index aa28cd0..f517294 100644 --- a/content/en/docs/languages/dart/basics.md +++ b/content/en/docs/languages/dart/basics.md @@ -290,8 +290,7 @@ Future recordRoute( await for (var location in request) { if (!timer.isRunning) timer.start(); pointCount++; - final feature = featuresDb.firstWhere((f) => f.location == location, - orElse: () => null); + final feature = featuresDb.firstWhereOrNull((f) => f.location == location); if (feature != null) { featureCount++; }