get method

Future<Map<String, dynamic>?> get(
  1. Resource resource, {
  2. String? token,
})

Fetch the given resource from this bridge.

token is the access token for remote access.

Will return null if:

  • The resource does not exist on this bridge
  • This bridge does not have an IP address
  • This bridge does not have an application key
  • Any other unforeseen error

Implementation

Future<Map<String, dynamic>?> get(
  Resource resource, {
  String? token,
}) async {
  if (ipAddress == null) return null;
  if (applicationKey == null) return null;

  try {
    return await HueHttpRepo.get(
      bridgeIpAddr: ipAddress!,
      pathToResource: resource.id,
      applicationKey: applicationKey!,
      resourceType: resource.type,
      token: token,
    );
  } catch (_) {
    return null;
  }
}