fiveesrd 0.1.1 copy "fiveesrd: ^0.1.1" to clipboard
fiveesrd: ^0.1.1 copied to clipboard

Typed REST and GraphQL client for the D&D 5e SRD API.

example/main.dart

import 'package:fiveesrd/fiveesrd.dart';

/// Simple console example showing how to use both the REST and GraphQL helpers.
Future<void> main() async {
  final client = FiveEsrdClient(options: ClientOptions(enableLogging: false));

  // Fetch a few level-1 spells via the REST API.
  final spells = await client.rest.listSpells(query: {'level': 1});
  final firstRestResult = spells.results?.first;
  if (firstRestResult != null) {
    print('First level-1 spell: ${firstRestResult.name}');
  }

  // Fetch monster summaries via GraphQL.
  final monsters = await client.graphql.monstersOverview(limit: 3);
  for (final monster in monsters.monsters) {
    final armorClass = monster.armorClass.isNotEmpty
        ? monster.armorClass.first.value
        : null;
    print('Monster ${monster.name} has AC ${armorClass ?? 'n/a'}');
  }
}
0
likes
0
points
16
downloads

Publisher

verified publisherundrapps.com

Weekly Downloads

Typed REST and GraphQL client for the D&D 5e SRD API.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

async, chopper, collection, dio, equatable, graphql, http, json_annotation, logging, meta

More

Packages that depend on fiveesrd