From 25c316ef797fcde5540a9b60855816a7f3b0dcba Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Tue, 5 Nov 2024 08:42:22 -0300 Subject: [PATCH] fix: improve null checks in localization storage updates --- .../services/localization/localization_service.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/shared/services/localization/localization_service.dart b/lib/shared/services/localization/localization_service.dart index 426049a7..2297accc 100644 --- a/lib/shared/services/localization/localization_service.dart +++ b/lib/shared/services/localization/localization_service.dart @@ -1,3 +1,5 @@ +// ignore_for_file: curly_braces_in_flow_control_structures + import 'dart:developer'; import 'package:flutter/material.dart'; @@ -272,10 +274,11 @@ class LocalizationService { } static Future _updateStorageUtil(Map jsonBody) async { - await StorageHelper.instance.set(SQLiteStorageKey.whatsapp.value, jsonBody['whatsapp'] ? 'true' : 'false', Storage.SQLiteStorage); - await StorageHelper.instance.set(SQLiteStorageKey.provisional.value, jsonBody['provisional'] ? 'true' : 'false', Storage.SQLiteStorage); - await StorageHelper.instance.set(SQLiteStorageKey.pets.value, jsonBody['pet'] ? 'true' : 'false', Storage.SQLiteStorage); + await StorageHelper.instance.set(SQLiteStorageKey.whatsapp.value, jsonBody['whatsapp'] == true && jsonBody['whatsapp'] != null ? 'true' : 'false', Storage.SQLiteStorage); + await StorageHelper.instance.set(SQLiteStorageKey.provisional.value, jsonBody['provisional'] == true && jsonBody['provisional'] != null ? 'true' : 'false', Storage.SQLiteStorage); + await StorageHelper.instance.set(SQLiteStorageKey.pets.value, jsonBody['pet'] == true && jsonBody['pet'] != null ? 'true' : 'false', Storage.SQLiteStorage); await StorageHelper.instance.set(SQLiteStorageKey.petAmount.value, jsonBody['petAmountRegister'].toString().isEmpty ? '0' : jsonBody['petAmountRegister'].toString(), Storage.SQLiteStorage); await StorageHelper.instance.set(SQLiteStorageKey.userName.value, jsonBody['visitado']['VDO_NOME'], Storage.SQLiteStorage); + } }