Flutter: remove all saved shared preferences
You can simply use clear()
function with your variable it will clear all the shared preferences.
SharedPreferences preferences = await SharedPreferences.getInstance();
await preferences.clear();
If you want to remove particular key value from shared preferences with key name you can do it like this way as follows.
SharedPreferences preferences = await SharedPreferences.getInstance();
await preferences.remove('KeyNameHere');
I use shared_preferences
plugin:
In pubspec.yaml
dependencies:
flutter:
sdk: flutter
shared_preferences: ^0.4.3
And in dart file:
import 'dart:async';
import 'package:shared_preferences/shared_preferences.dart';
...
SharedPreferences preferences = await SharedPreferences.getInstance();
await preferences.clear();
I think this is what you need