From eebe6c00ae885e67b122c480bbdfbc0d39a94abe Mon Sep 17 00:00:00 2001 From: BrightDV <92821484+BrightDV@users.noreply.github.com> Date: Thu, 2 May 2024 21:15:05 +0200 Subject: [PATCH] [team details] fix wrong DNFs --- lib/Screens/team_details.dart | 8 ++++---- lib/api/ergast.dart | 12 ++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/Screens/team_details.dart b/lib/Screens/team_details.dart index aeca947..f26f09c 100644 --- a/lib/Screens/team_details.dart +++ b/lib/Screens/team_details.dart @@ -462,10 +462,10 @@ class TeamResults extends StatelessWidget { 5, ), if (snapshot.data![index - 1].length > 1) - DriverResultItem( - snapshot.data![index - 1][1], - 5, - ), + DriverResultItem( + snapshot.data![index - 1][1], + 5, + ), ], ), ) diff --git a/lib/api/ergast.dart b/lib/api/ergast.dart index 8f1326f..e110b73 100644 --- a/lib/api/ergast.dart +++ b/lib/api/ergast.dart @@ -417,7 +417,10 @@ class _ErgastApiCalls { race['Results'][0]['Driver']['familyName'], race['Results'][0]['Driver']['code'], race['Results'][0]['Constructor']['constructorId'], - race['Results'][0]['Time']?['time'] ?? 'DNF', + race['Results'][0]['positionText'] == 'R' + ? 'DNF' + : race['Results'][0]['Time']?['time'] ?? + race['Results'][0]['status'], int.parse(race['Results'][0]['FastestLap']?['rank'] ?? '20') == 1 ? true : false, @@ -427,6 +430,7 @@ class _ErgastApiCalls { points: race['Results'][0]['points'], raceId: race['Circuit']['circuitId'], raceName: race['raceName'], + status: race['Results'][0]['status'], ), if (race['Results'].length > 1) DriverResult( @@ -437,7 +441,10 @@ class _ErgastApiCalls { race['Results'][1]['Driver']['familyName'], race['Results'][1]['Driver']['code'], race['Results'][1]['Constructor']['constructorId'], - race['Results'][1]['Time']?['time'] ?? 'DNF', + race['Results'][1]['positionText'] == 'R' + ? 'DNF' + : race['Results'][1]['Time']?['time'] ?? + race['Results'][1]['status'], int.parse(race['Results'][1]['FastestLap']?['rank'] ?? '20') == 1 ? true : false, @@ -447,6 +454,7 @@ class _ErgastApiCalls { points: race['Results'][1]['points'], raceId: race['Circuit']['circuitId'], raceName: race['raceName'], + status: race['Results'][1]['status'], ), ], );