getBool static method

bool getBool(
  1. String key, {
  2. bool defaultValue = false,
})

获取布尔值类型的数据

key 要获取的键 defaultValue 若没有对应 key 返回的默认值,默认为 false

示例:

bool firstOpen = SharepUtil.getBool('isFirstOpen', defaultValue: true);
print(firstOpen); // 例如: true

返回结果: bool 读取到的布尔值

Implementation

static bool getBool(String key, {bool defaultValue = false}) {
  return _prefs?.getBool(key) ?? defaultValue;
}