blue_alliance_client 0.1.0

blue_alliance_client #

A simple library to handle caching and authentication for API requests to The Blue Alliance, a popular database for the FIRST Robotics Competition.

Three cache implementations are provided - a MemoryCache, a FileSystemCache, and an IndexedDBCache - as well as a TbaCacheCompressor that can sit between the client and the cache.

See also The Blue Alliance's API documentation.

0.1.0 #

  • Caching and authentication
  • Compression utility


import 'dart:convert';
import 'dart:io';

import 'package:blue_alliance_client/blue_alliance_client.dart';
import 'package:blue_alliance_client/io.dart';

const apiBase = '';

const teams = ['frc624', 'frc1477', 'frc5892'];

void main() async {
  var client = TbaClient(await File('key.txt').readAsString(),
      cache: TbaCacheCompressor(FileSystemCache('cache')));

  for (var team in teams) {
    var stats = ClimbStats();
    var matches =
        (jsonDecode((await client.get('$apiBase/team/$team/matches/2019')).body)
                as List)
            .whereType<Map<String, dynamic>>();

    for (var match in matches.where((m) => m['score_breakdown'] != null)) {
      switch (() {
        var alliances = match['alliances'];
        var blue = alliances['blue']['team_keys'];
        var red = alliances['red']['team_keys'];

        var breakdown = match['score_breakdown'];
        var blueBreakdown = breakdown['blue'];
        var redBreakdown = breakdown['red'];

        if (blue[0] == team) {
          return blueBreakdown['endgameRobot1'];
        } else if (blue[1] == team) {
          return blueBreakdown['endgameRobot2'];
        } else if (blue[2] == team) {
          return blueBreakdown['endgameRobot3'];
        } else if (red[0] == team) {
          return redBreakdown['endgameRobot1'];
        } else if (red[1] == team) {
          return redBreakdown['endgameRobot2'];
        } else if (red[2] == team) {
          return redBreakdown['endgameRobot3'];
        } else {
          throw 'a team\'s match did not involve it: ${match['key']} for $team';
      }()) {
        case 'HabLevel1':
        case 'HabLevel2':
        case 'HabLevel3':

    print('$team: $stats');


class ClimbStats {
  int noClimb = 0;
  int hab1 = 0;
  int hab2 = 0;
  int hab3 = 0;

  String toString() =>
      'noClimb = $noClimb, hab1 = $hab1, hab2 = $hab2, hab3 = $hab3';

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  blue_alliance_client: ^0.1.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:blue_alliance_client/blue_alliance_client.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 12, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

Health suggestions

Format lib/blue_alliance_client.dart.

Run dartfmt to format lib/blue_alliance_client.dart.

Format lib/html.dart.

Run dartfmt to format lib/html.dart.

Format lib/io.dart.

Run dartfmt to format lib/io.dart.

Format lib/src/caching/cache_provider.dart.

Run dartfmt to format lib/src/caching/cache_provider.dart.

Maintenance suggestions

The package description is too short. (-8 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
archive ^2.0.0 2.0.13
http ^0.12.0 0.12.0+4
path ^1.6.0 1.6.4
Transitive dependencies
args 1.5.2
async 2.4.0
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.4
http_parser 3.1.3
meta 1.1.8
pedantic 1.9.0
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
test ^1.6.0