fetchDataRecords method
Future<List<IOSWKWebsiteDataRecord> >
fetchDataRecords({
- required Set<
IOSWKWebsiteDataType> dataTypes,
Fetches data records containing the given website data types.
dataTypes
represents the website data types to fetch records for.
Implementation
Future<List<IOSWKWebsiteDataRecord>> fetchDataRecords(
{required Set<IOSWKWebsiteDataType> dataTypes}) async {
List<IOSWKWebsiteDataRecord> recordList = [];
Set<WebsiteDataType> dataTypesList = Set();
for (var dataType in dataTypes) {
dataTypesList
.add(WebsiteDataType.fromNativeValue(dataType.toNativeValue())!);
}
List<WebsiteDataRecord> records = await WebStorageManager.instance()
.fetchDataRecords(dataTypes: dataTypesList);
for (var record in records) {
Set<WebsiteDataType> dataTypesString = record.dataTypes ?? Set();
Set<IOSWKWebsiteDataType> dataTypes = Set();
for (var dataTypeValue in dataTypesString) {
var dataType =
IOSWKWebsiteDataType.fromNativeValue(dataTypeValue.toNativeValue());
if (dataType != null) {
dataTypes.add(dataType);
}
}
recordList.add(IOSWKWebsiteDataRecord(
displayName: record.displayName, dataTypes: dataTypes));
}
return recordList;
}