Browse SDKs · Flutter
Platform
SDKsFlutter

Create a location message

Create a location message with the OpenIM Flutter SDK.

Copy

Construct a geographical location message object with latitude, longitude coordinates, and a place description:

Parameters

ParameterTypeRequiredDescription
latitudedoubleYesLatitude coordinate.
longitudedoubleYesLongitude coordinate.
descriptionStringYesLocation description or landmark name (for example, "Taipei 101").

Code example

final message = await OpenIM.iMManager.messageManager.createLocationMessage(
  latitude: 25.033,
  longitude: 121.5654,
  description: 'Taipei 101',
);

Ensure your application obtains device location permissions and verifies coordinate validity before calling this method.

Return value

Returns a Future resolving to a location Message object ready for transmission. Its location payload is stored in locationElem.

State changes after the call

Creating a message only constructs the local message data structure in memory; it does not perform network transmission and does not trigger new-message event callbacks. Once constructed, pass the returned Message instance to Send a message to deliver it to a direct or group conversation.