shared preferences flutter code example

Example 1: delete shared preference flutter

import 'dart:async';
import 'package:shared_preferences/shared_preferences.dart';
...
SharedPreferences preferences = await SharedPreferences.getInstance();
await preferences.clear();

Example 2: shared prefs flutter

dependencies:
  shared_preferences: ^0.5.12+4

Example 3: flutter sharedpreferences

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

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

Tags:

Misc Example