flutter sharedpreferences code example

Example 1: shared prefs flutter

dependencies:
  shared_preferences: ^0.5.12+4

Example 2: android sharedpreferences

SharedPreferences sharedPref = getSharedPreferences("name", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString("key", "Value");
editor.commit();

Example 3: flutter sharedpreferences

@override
  void initState() {
    super.initState();
    asyncMethod();
  }

  void asyncMethod() async {
    await asyncCall1();
    await asyncCall2();
    // ....
  }

Tags:

Misc Example