getResource method
Future<List<Map<String, dynamic> > ?>
getResource(
- ResourceType type, {
- String decrypter(
- String ciphertext
Fetch all resources of the given resource type
from this bridge.
decrypter
When the old tokens are read from local storage, they are
decrypted. This parameter allows you to provide your own decryption
method. This will be used in addition to the default decryption method.
This will be performed after the default decryption method.
Will return null
if:
- This bridge does not have an IP address
- This bridge does not have an application key
- Any other unforeseen error
Implementation
Future<List<Map<String, dynamic>>?> getResource(
ResourceType type, {
String Function(String ciphertext)? decrypter,
}) async {
if (ipAddress == null) return null;
if (applicationKey == null) return null;
try {
final Map<String, dynamic>? result = await HueHttpRepo.get(
bridgeIpAddr: ipAddress!,
applicationKey: applicationKey!,
resourceType: type,
decrypter: decrypter,
);
if (result == null) return null;
return MiscTools.extractDataList(result);
} catch (_) {
return null;
}
}