I have a simple question regering the shared_preferences package in flutter.

Is it safe to get an instance of SharedPreferences and store that for future use or is it best to always get a new reference each time?

To clarify, which of these two are the proper or best way of doing it?

SharedPreferences preferences;

void init() async {
  preferences = await SharedPreferences.getInstance();
}

void setValue(String key, String value)  async{
  await preferences.setString(key, value);
}
void setValue(String key, String value) async {
  final preferences = await SharedPreferences.getInstance();
  await preferences.setString(key, value);
}