Skip to main content
GuidesAPI ReferenceExamplesFAQ

Location Wikipedia

Estimated reading time: 2 minutes

Landmarks can include Wikipedia data such as title, image title, URL, description, page summary, language, and more. To demonstrate how to retrieve Wikipedia information, we introduce the ExternalInfo class, which handles Wikipedia data.

ExternalInfo class

This class provides Wikipedia information for a landmark. An ExternalInfo object is obtained using the static method getExternalInfo of the ExternalInfo class.

final completer = Completer<ExternalInfo?>();

ExternalInfo.getExternalInfo(
landmark,
onWikiDataAvailable: (externalInfo) => completer.complete(externalInfo),
);

final externalInfo = await completer.future;
warning

The method returns an ExternalInfo object, which should not be accessed before the onWikiDataAvailable callback completes.

note

The onWikiDataAvailable callback might return null if no Wikipedia info is available for the given lmk. To check this before calling getExternalInfo, use the following code:

final ExternalInfo pExternalInfo = ExternalInfo();

final bool hasExternalInfo = pExternalInfo.hasWikiInfo(landmark);

Wikipedia data

Wikipedia information can be accessed using methods provided by the ExternalInfo object. The following table explains each method:

MethodReturn TypeDescription
getWikiImageDescriptionStringGet Wikipedia image description directly, without notifier.
getWikiImagesCountintGet the count of the images on the Wikipedia page.
getWikiImageTitleStringGet Wikipedia image title directly, without notifier.
getWikiImageUrlStringGet Wikipedia image URL directly, without notifier.
getWikiPageDescriptionStringGet Wikipedia page summary (text).
getWikiPageLanguageStringGet Wikipedia page language.
getWikiPageTitleStringGet Wikipedia page title.
getWikiPageUrlStringGet Wikipedia page URL.
hasWikiInfoboolChecks if the landmark has Wikipedia info.
info

Wikipedia data is provided in the language specified in SDKSettings. Learn more about setting the SDK language here.