searchCountries static method
Search for countries using a query string.
This method performs a top-level address search, restricted to country-level results.
Parameters
- IN filter The filter string to apply to the country names. If empty, all countries are returned (subject to engine limits).
- IN onComplete Will be invoked when the search operation is completed, providing the search results and an error code.
Returns
- Associated TaskHandler for this operation if the search can be started; otherwise null.
Throws
- An exception if it fails to initiate.
Implementation
static TaskHandler? searchCountries(
final String filter,
final void Function(GemError err, List<Landmark> landmarks) onComplete,
) {
final EventDrivenProgressListener progListener =
EventDrivenProgressListener();
GemKitPlatform.instance.registerEventHandler(progListener.id, progListener);
final LandmarkList results = LandmarkList();
final Landmark emptyParent = Landmark();
progListener.registerOnCompleteWithDataCallback((
final int err,
final String hint,
final Map<dynamic, dynamic> json,
) {
GemKitPlatform.instance.unregisterEventHandler(progListener.id);
if (err == GemError.success.code || err == GemError.reducedResult.code) {
onComplete(GemErrorExtension.fromCode(err), results.toList());
} else {
onComplete(GemErrorExtension.fromCode(err), <Landmark>[]);
}
});
final OperationResult resultString = staticMethod(
'GuidedAddressSearchService',
'search',
args: <String, dynamic>{
'results': results.pointerId,
'parent': emptyParent.pointerId,
'filter': filter,
'detailToSearch': AddressDetailLevel.country.id,
'progress': progListener.id,
},
);
final int errorCode = resultString['result'];
if (errorCode != GemError.success.code) {
onComplete(GemErrorExtension.fromCode(errorCode), <Landmark>[]);
return null;
}
return TaskHandlerImpl(progListener.id);
}