From 61c07d55e0b8a05430734c98e2d1e30af574f790 Mon Sep 17 00:00:00 2001 From: jinyus <30532952+jinyus@users.noreply.github.com> Date: Thu, 7 Jan 2021 03:17:19 -0500 Subject: [PATCH] Fix null comparison error The program would crash if null was passed to validateQuality because the null check was being done last. The comparison "null < 10" was done which resulted in the crash. Fixed by doing the null check first. --- lib/validators.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/validators.dart b/lib/validators.dart index fb8b286..3920219 100644 --- a/lib/validators.dart +++ b/lib/validators.dart @@ -4,7 +4,7 @@ const DEFAULT_THUMB_QUALITY = 50; const DEFAULT_IMAGE_TYPE = ThumbFormat.JPEG; int validateQuality(int choice) { - if (choice < 10 || choice > 100 || choice == null) + if (choice == null || choice < 10 || choice > 100) return DEFAULT_THUMB_QUALITY; return choice; }