nasa 0.0.4 copy "nasa: ^0.0.4" to clipboard
nasa: ^0.0.4 copied to clipboard

The easiest and powerful Dart/Flutter library for NASA APIs.

example/example.dart

// Copyright 2023 Kato Shinya. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided the conditions.

import 'package:nasa/nasa.dart';

Future<void> main() async {
  final nasa = NasaApi(
    token: 'YOUR_TOKEN_HERE',

    //! Automatic retry is available when server error or network error occurs
    //! when communicating with the API.
    retryConfig: RetryConfig(
      maxAttempts: 5,
      onExecute: (event) => print(
        'Retry after ${event.intervalInSeconds} seconds...'
        '[${event.retryCount} times]',
      ),
    ),

    //! The default timeout is 10 seconds.
    timeout: Duration(seconds: 20),
  );

  try {
    final apod = await nasa.apod.lookupImage();

    print(apod);
  } on UnauthorizedException catch (e) {
    print(e);
  } on RateLimitExceededException catch (e) {
    print(e);
  } on DataNotFoundException catch (e) {
    print(e);
  } on NasaException catch (e) {
    print(e);
  }
}
11
likes
140
pub points
51%
popularity

Publisher

verified publishershinyakato.dev

The easiest and powerful Dart/Flutter library for NASA APIs.

Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

freezed_annotation, http, intl, json_annotation, universal_io

More

Packages that depend on nasa