getLink static method

String getLink({
  1. required String username,
  2. String? message,
})

Get Telegram message link as String

Implementation

static String getLink({required String username, String? message}) {
  Uri? url;
  try {
    if (message != null && message != '') {
      url =
          Uri.parse('https://t.me/$username?text=${Uri.encodeFull(message)}');
    } else {
      url = Uri.parse('https://t.me/$username');
    }
  } catch (e) {
    if (kDebugMode) {
      print('\x1B[31mGenerating link failed!\nError: $e\x1B[0m');
    }
  }
  return url.toString();
}