It seems like the flutter_secure_storage package stores the items in the list randomly. 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. 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
}
)
}