Skip to content

Instantly share code, notes, and snippets.

@Vanethos
Created September 5, 2019 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vanethos/a8e756b88262caef440135368b2540ee to your computer and use it in GitHub Desktop.
Save Vanethos/a8e756b88262caef440135368b2540ee to your computer and use it in GitHub Desktop.
dynamic responseInterceptor(Response options) async {
if (options.headers.value("verifyToken") != null) {
//if the header is present, then compare it with the Shared Prefs key
SharedPreferences prefs = await SharedPreferences.getInstance();
var verifyToken = prefs.get("VerifyToken");
// if the value is the same as the header, continue with the request
if (options.headers.value("verifyToken") == verifyToken) {
return options;
}
}
return DioError(request: options.request, message: "User is no longer active");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment