getBool abstract method

bool getBool(
  1. String key,
  2. bool defaultValue
)

Gets a boolean value. Returns defaultValue if the key is missing or the stored type is not bool. key Lookup key. defaultValue Value to return when not found or type mismatch. Returns Stored bool or defaultValue.

Example:

// Retrieve boolean values with defaults
bool isPremium = _userStorage!.getBool("is_premium", false);
bool notificationsEnabled = _userStorage!.getBool(
 "notifications_enabled",
 true,
);
bool nonExistentBool = _userStorage!.getBool("non_existent_bool", false);
print("Is premium: $isPremium");
print("Notifications enabled: $notificationsEnabled");
print("Non-existent bool: $nonExistentBool");

Implementation

bool getBool(String key, bool defaultValue);