changeSkin function Null safety

Future<bool> changeSkin(
  1. Uri skinUrl,
  2. String accessToken,
  3. [SkinModel skinModel = SkinModel.classic]
)

Change the skin with the texture of the skin at skinUrl.

Implementation

Future<bool> changeSkin(Uri skinUrl, String accessToken,
    [SkinModel skinModel = SkinModel.classic]) async {
  final headers = {
    'authorization': 'Bearer $accessToken',
  };
  final data = {
    'variant': skinModel.toString().replaceFirst('SkinModel', ''),
    'url': skinUrl,
  };
  final response = await requestBody(
      http.post, _minecraftServicesApi, 'minecraft/profile/skins', data,
      headers: headers);
  switch (response.statusCode) {
    case 401:
      throw AuthException(AuthException.invalidCredentialsMessage);
  }
  return true;
}