fromJson static method

TapResult fromJson(
  1. Map<String, Object?> json
)

Restores a verdict from the JSON envelope (round trips with toJson). An unknown shape refuses honestly as TapError.

Implementation

static TapResult fromJson(Map<String, Object?> json) {
  switch (json['result']) {
    case 'found':
      return const TapFound();
    case 'disabled':
      return const TapDisabled();
    case 'notFound':
      return const TapNotFound();
    case 'error':
      final message = json['message'];
      return TapError(message is String ? message : 'unknown driver error');
    default:
      return TapError('unknown TapResult envelope: $json');
  }
}