getUserPreferences static method

Future<UserMetaPreference?> getUserPreferences({
  1. required String token,
})

Implementation

static Future<UserMetaPreference?> getUserPreferences({required String token}) async {
  final url = Uri.parse(
    ApiEndPoint.userMeta,
  );
  Map<String, String> header = {'Content-Type': 'application/json', "Authorization": token};
  var result = await http.get(
    url,
    headers: header,
  );

  if (result.statusCode == 200) {
    List response = jsonDecode(result.body);
    if (response.isNotEmpty) {
      UserMetaPreference userMetaPreference = UserMetaPreference.fromJson(response.first);
      return userMetaPreference;
    } else {
      return null;
    }
  }
  return null;
}