ground_control_client 0.17.0 copy "ground_control_client: ^0.17.0" to clipboard
ground_control_client: ^0.17.0 copied to clipboard

A client library for the Serverpod Ground Control API. Used to manage Serverpod Cloud projects.

example/main.dart

import 'package:ground_control_client/ground_control_client.dart';

// This is the URL to the server and should be replaced with the actual URL to
// the server.
var url = 'http://localhost:8080/';

Future<void> main() async {
  var client = Client(
    url,
  )..authKeyProvider = _SimpleAuthenticationKeyManager('mock-token');

  client.close();
}

// Simple implementation for managing authentication keys.
class _SimpleAuthenticationKeyManager implements ClientAuthKeyProvider {
  String? _key;

  _SimpleAuthenticationKeyManager(this._key);

  @override
  Future<String?> get authHeaderValue async {
    return switch (_key) {
      final String key => wrapAsBearerAuthHeaderValue(key),
      null => null,
    };
  }
}