Skip to content

Commit

Permalink
remove force unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-sidhdhi-p committed Apr 10, 2024
1 parent 1fe4639 commit c30b9c5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ extension MatchModelString on MatchModel {
final secondTeam =
teams.firstWhere((element) => element.team.id != firstTeam.team.id);

if (firstTeam.run! > secondTeam.run!) {
if ((firstTeam.run ?? 0) > (secondTeam.run ?? 0)) {
// first batting team won
final teamName = firstTeam.team.name;

final runDifference = firstTeam.run! - secondTeam.run!;
final runDifference = (firstTeam.run ?? 0) - (secondTeam.run ?? 0);

return (
teamName: teamName,
Expand Down
4 changes: 2 additions & 2 deletions khelo/lib/ui/flow/matches/add_match/add_match_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ class _AddMatchScreenState extends ConsumerState<AddMatchScreen> {
addMatchViewStateProvider.select((value) => value.pushTossDetailScreen),
(previous, next) {
if (next == true) {
AppRoute.addTossDetail(matchId: matchId ?? "INVALID ID")
AppRoute.addTossDetail(matchId: ref.read(addMatchViewStateProvider.notifier).matchId ?? "INVALID ID")
.pushReplacement(context);
} else if (next == false) {
AppRoute.scoreBoard(matchId: matchId ?? "INVALID ID")
AppRoute.scoreBoard(matchId: ref.read(addMatchViewStateProvider.notifier).matchId ?? "INVALID ID")
.pushReplacement(context);
}
});
Expand Down
9 changes: 7 additions & 2 deletions khelo/lib/ui/flow/matches/match_list_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,13 @@ class MatchListScreen extends ConsumerWidget {
if (match.match_status == MatchStatus.yetToStart) {
AppRoute.addMatch(matchId: match.id).push(context);
} else {
AppRoute.scoreBoard(matchId: match.id ?? "INVALID_ID")
.push(context);
if (match.toss_decision == null || match.toss_winner_id == null) {
AppRoute.addTossDetail(matchId: match.id ?? "INVALID_ID")
.push(context);
} else {
AppRoute.scoreBoard(matchId: match.id ?? "INVALID_ID")
.push(context);
}
}
},
icon: Icon(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ class _SelectPlayerSheetState extends ConsumerState<SelectPlayerSheet> {
: state.otherInning?.team_id) ??
"INVALID ID";
final teamPlayers = state.match?.teams
.firstWhere((element) => element.team.id == teamId)
.squad;
.where((element) => element.team.id == teamId)
.firstOrNull
?.squad;

if (type == PlayerSelectionType.bowler) {
return teamPlayers ?? [];
Expand Down

0 comments on commit c30b9c5

Please sign in to comment.