i'm pretty new to flutter and i want to add singleton in my flutter app. I used shared preferences to save my private and public key, but also i want to take this info from it when i launch app
try {
     userPubKey = getPublicKey() as String;
     userPrivateKey = getPrivateKey() as String;
   } catch (e) {
   }
   if (userPrivateKey == "null" || userPubKey == "null") {
     var crypter = RsaCrypt();
     var pubKey = crypter.randPubKey;
     var privKey = crypter.randPrivKey;
     String pubKeyString = crypter.encodeKeyToString(pubKey);
     String privKeyString = crypter.encodeKeyToString(privKey);
     setPublicKey(pubKeyString);
     setPrivateKey(privKeyString);
     userPubKey = pubKeyString;
     userPrivateKey = privKeyString;
   } 
Here is my singleton screen. I need to add my pubKey, privateKey, UId and userName data in Singleton. I copied random singleton code with factory construct.
class Singleton {
  Singleton.privateConstructor();
  static final Singleton instance = Singleton.privateConstructor();
  factory Singleton() {
    return instance;
  }
  String pubKey;
  String privateKey;
  String userName;
  String userID;
  setPubKey(String key){
    this.pubKey = key;
  }
  String getPubKey(){
    return this.pubKey;
  }
}
