I'm trying to test this function:
void store(String x, String y) async {
Map<String, dynamic> map = {
'x': x,
'y': y,
};
var jsonString = json.encode(map);
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setString('fileName', jsonString);
}
I saw that I can populate the shared preferences with
const MethodChannel('plugins.flutter.io/shared_preferences')
.setMockMethodCallHandler((MethodCall methodCall) async {
if (methodCall.method == 'getAll') {
return <String, dynamic>{}; // set initial values here if desired
}
return null;
});
But I didn't understand how to use, expecially in my case.