Untitled

 avatar
faisalsalameh
dart
a year ago
649 B
1
Indexable
Never
Future<bool> updaetToken() async {
    Ref ref = Ref(refreshToken: appUser.state.tokens.refresh!.token!);
    http.Response response = await http.post(
      Uri.parse(ApiString.refreshTokens),
      body: ref.toJson(),
    );
    if (response.statusCode == 200) {
      appUser.state.tokens = Tokens.fromJson(
        json.decode(response.body) as Map<String, dynamic>,
      );
      AppTools().saveTokenInStorage();
      return true;
    } else {
      errorModel = ErrorModel.fromJson(
        json.decode(response.body) as Map<String, dynamic>,
      );
      AppTools().errorDialog(errorModel.message!.toString());
    }
    return false;
  }