![](/img/trans.png)
[英]No implementation found for method write on channel plugins.it_nomads.com/flutter_secure_storage
[英]How would I keep the order of the list stored flutter_secure_storage?
似乎flutter_secure_storage package 随机存储列表中的项目。 是否有一种简单的解决方法可以按照写入列表/存储的顺序将项目保留在列表/存储中? 我正在尝试创建的内容具有常规列表的常规列表视图,并且在点击 listtile 时,它应该引用安全列表中的相同索引,但这不是按顺序排列的。 这是一些快速示例代码:
List<String> items = [];
List<SecIUtems> secItems= []; //the secure list
final _storage = FlutterSecureStorage();
changeUserInput(){
//get user input via dialog box
newInput = //something the user input;
//code to mix up and add random stuff to newInput to make it a password or something
}
@override
void initState() {
super.initState();
_readAll();
}
Future<Null> _readAll() async {
final all = await _storage.readAll();
setState(() {
return _items = all.keys
.map((key) => _SecItem(key, all[key]))
.toList(growable: false);
});
}
void addToList(){
changeUserInput();
final String key = somerandomValue();
final String value = somerandomValue();
items.add(newInput);
await _storage.write(key: key, value: value);
_readAll();
}
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
title: Text('help'),
actions: <Widget>[
IconButton(
onPressed: addToList,
icon: Icon(Icons.add)),
listview.builder{
itemCount: items.length,
itemBuilder: (BuildContext context, in index) => ListTile(
title: Text(items[index]),
onPressed: (){
print(secItems[index].value); //actual code copies the emcrypted password to clipboard. Hence the tile clicked on needs to correspond to the correct secured password
}
)
}
钥匙串适用于小块数据:
钥匙串服务 API 通过为您的应用提供一种机制,将少量用户数据存储在称为钥匙串的加密数据库中,从而帮助您解决此问题。 当您安全地记住他们的密码时,您可以让用户选择一个复杂的密码。 https://developer.apple.com/documentation/security/keychain_services#//apple_ref/doc/uid/TP30000897-CH203-TP1
所以使用加密存储解决方案,即:sqflite,然后加密该数据是一个更好的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.