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.
This commit is contained in:
M. Hanif Shahy 2024-04-02 19:16:02 +04:30 committed by GitHub
parent a59839a611
commit 0c569cb5ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 2 deletions

View File

@ -290,8 +290,7 @@ Future<RouteSummary> 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++;
}