isApiKeyValid static method

Future<bool> isApiKeyValid(
  1. String apiKey
)

Checks if the provided apiKey is valid by making a request to NASA's API

Implementation

static Future<bool> isApiKeyValid(String apiKey) async {
  final response = await get(Uri.parse('https://api.nasa.gov/mars-photos/api/v1/manifests/perseverance?api_key=$apiKey'));

  if (response.statusCode != 200) {
    return false;
  } else {
    return true;
  }
}