KeychainUtil class

安全存储工具类

提供一些常用的安全存储方法, 如读取、写入、删除。 iOS端存储到钥匙串,Android端存储到KeyStore。

使用示例:

void example() async {
  // 写入
  bool writeResult = await KeychainUtil.write(key: 'my_key', value: 'my_value');
  print('写入结果: $writeResult');

  // 读取
  String? value = await KeychainUtil.read(key: 'my_key');
  print('读取到的值: $value');

  // 删除
  bool deleteResult = await KeychainUtil.delete(key: 'my_key');
  print('删除结果: $deleteResult');
}

Constructors

KeychainUtil()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

storage → FlutterSecureStorage
获取安全存储实例
no setter

Static Methods

delete({required String key}) Future<bool>
删除指定键值
read({required String key}) Future<String?>
读取指定键的值
write({required String key, required String value}) Future<bool>
写入指定键值对