I just created a username login screen and I store that data in shared preferences. But when I register the new user, the old data (username, password) overwritten. Is there just 1 data for 1 key ? I will use sql lite if necessary but I just wondered. Thanks in advance.
CodePudding user response:
You can use a list instead of one data
Save:
prefs.setStringList('key', yourList);
Retrieve:
var yourList = prefs.getStringList('key');
CodePudding user response:
You have to remove the older value every time when you register a new user for example you have a register button so every time user press that you should provide a remove value line
for instance:
ElevatedButton(
onPressed: ()async{
var removeval = await prefs.remove("//your key here") }
child: Text("Register")
)