getBool static method

Future<bool> getBool(
  1. String key, [
  2. bool defValue = false
])

获取bool类型数据,如果没有则返回默认值 keydefValue 默认值:默认为false

Implementation

static Future<bool> getBool(String key, [bool defValue = false]) async {
  SharedPreferences prefs = await SharedPreferences.getInstance();
  bool? value = prefs.getBool(key) ?? defValue;
  _println('getBool', key, value);
  return value;
}