简体   繁体   中英

How to create more than one Shared-Preferences on Flutter?

I created 2 shared preferences files. But automatically remove the first file. How to create multiple shared preferences files in Flutter?

First file

Future<bool> saveUrlPreference(String token,String refreshToken) async {
  List<String> tokens = [token,refreshToken];
  SharedPreferences pref = await SharedPreferences.getInstance();
  pref.setStringList('tokens', tokens);
  return pref.commit();
}

Second file

Future<bool> saveUrlPreference(String Url) async {
  SharedPreferences pref = await SharedPreferences.getInstance();
  pref.setString("url", Url);
  return pref.commit();
}

This is not yet supported

Upvote and follow https://github.com/flutter/flutter/issues/14337

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM