Your _sharedPreferences
instance is not initialized.
Future<bool> commit() async {
_sharedPreferences ??= await SharedPreferences.getInstance();
await _sharedPreferences.setString(ID, id);
}
CLICK HERE to find out more related problems solutions.