简体   繁体   English

我将如何保持存储flutter_secure_storage的列表顺序?

[英]How would I keep the order of the list stored flutter_secure_storage?

It seems like the flutter_secure_storage package stores the items in the list randomly.似乎flutter_secure_storage package 随机存储列表中的项目。 Is there a simple workaround to keep the items in the list/storage in the order they were written into the list/storage?是否有一种简单的解决方法可以按照写入列表/存储的顺序将项目保留在列表/存储中? What I'm trying to create has a regular listview of a regular list and when tapping on a listtile, it should refer to the same index in the secure list, but that isn't in order.我正在尝试创建的内容具有常规列表的常规列表视图,并且在点击 listtile 时,它应该引用安全列表中的相同索引,但这不是按顺序排列的。 Here is some quick sample code:这是一些快速示例代码:

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
  }
  )
}





Keychain is meant for small chunks of data:钥匙串适用于小块数据:

The keychain services API helps you solve this problem by giving your app a mechanism to store small bits of user data in an encrypted database called a keychain.钥匙串服务 API 通过为您的应用提供一种机制,将少量用户数据存储在称为钥匙串的加密数据库中,从而帮助您解决此问题。 When you securely remember the password for them, you free the user to choose a complicated one.当您安全地记住他们的密码时,您可以让用户选择一个复杂的密码。 https://developer.apple.com/documentation/security/keychain_services#//apple_ref/doc/uid/TP30000897-CH203-TP1 https://developer.apple.com/documentation/security/keychain_services#//apple_ref/doc/uid/TP30000897-CH203-TP1

So using an encrypted storage solution, ie: sqflite and then encrypt that data is a better solution.所以使用加密存储解决方案,即:sqflite,然后加密该数据是一个更好的解决方案。

A link to how to encrypt sqfite do this is: https://stackoverflow.com/questions/50232418/how-to-encrypt-the-sqlite-database-in-flutterhttps://stackoverflow.com/questions/50232418/how-to-encrypt-the-sqlite-database-in-flutter如何加密 sqfite 的链接是: https://stackoverflow.com/questions/50232418/how-to-encrypt-the-sqlite-database-in-flutterhttps://stackoverflow.com/questions/50232418/how -to-encrypt-the-sqlite-database-in-flutter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未找到在通道插件上写入方法的实现。it_nomads.com/flutter_secure_storage - No implementation found for method write on channel plugins.it_nomads.com/flutter_secure_storage 在 flutter 中构建应用程序时,SharedPrefernces 和 Flutter_secure_storage 包有什么区别? 还是他们做同样的事情? - What is the difference between SharedPrefernces and Flutter_secure_storage packages when building an app in flutter? or do they do the same thing? 帐户删除安全存储颤振 - Account Deletion Secure Storage Flutter 如何实现音频流应用和安全存储 - How to implement audio streaming app and secure storage in flutter 如何将项目添加到 Dart Flutter 安全存储字符串列表? - How to add item to Dart Flutter Secure Storage stringList? 如何保护存储的数据 - How to secure stored data 我将如何处理从Android应用程序到服务器的安全通信 - How would I approach secure communication from Android application to Server 如何防止在 Dart Flutter 安全存储中重新保存以前保存的数据? - How to prevent re-saving of previously saved data in Dart Flutter Secure Storage? 如何从线程将项目添加到列表并保持添加顺序? - How can I add items to a list from a thread and keep the adding order? 如何在颤动中按字母顺序对外部存储中的歌曲列表进行排序 - how to sort list of songs from external storage alphabetically in flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM