getLocationImage function

Widget getLocationImage(
  1. LocationChatMessage? locationChatMessage,
  2. double width,
  3. double height, {
  4. bool isSelected = false,
})

Implementation

Widget getLocationImage(
    LocationChatMessage? locationChatMessage, double width, double height,
    {bool isSelected = false}) {
  return InkWell(
      onTap: isSelected
          ? null
          : () async {
              String googleUrl =
                  '${Constants.googleMapQuery}${locationChatMessage!.latitude}, ${locationChatMessage.longitude}';
              if (await canLaunchUrl(Uri.parse(googleUrl))) {
                await launchUrl(Uri.parse(googleUrl));
              } else {
                throw 'Could not open the map.';
              }
            },
      child: CachedNetworkImage(
        imageUrl: Helper.getMapImageUri(
            locationChatMessage!.latitude, locationChatMessage.longitude),
        errorWidget: (c, l, er) {
          return Center(
            child: Text(MirrorflyUikit.instance.googleMapKey.isEmpty
                ? AppConstants.googleMapKeyIsRequired
                : AppConstants.invalidMapKey),
          );
        },
        width: width,
        height: height,
        fit: BoxFit.fill,
      )
      /*child: Image.network(
        Helper.getMapImageUri(
            locationChatMessage!.latitude, locationChatMessage.longitude),
        fit: BoxFit.fill,
        width: width,
        height: height,
      )*/
      );
}