shareTwitter static method

Future<String?> shareTwitter(
  1. String captionText, {
  2. List<String>? hashtags,
  3. String? url,
  4. String? trailingText,
})

Implementation

static Future<String?> shareTwitter(String captionText,
    {List<String>? hashtags, String? url, String? trailingText}) async {
  Map<String, dynamic> args;
  String modifiedUrl;
  if (Platform.isAndroid) {
    modifiedUrl = Uri.parse(url ?? '').toString().replaceAll('#', "%23");
  } else {
    modifiedUrl = Uri.parse(url ?? '').toString();
  }
  if (hashtags != null && hashtags.isNotEmpty) {
    String tags = "";
    hashtags.forEach((f) {
      tags += ("%23" + f.toString() + " ").toString();
    });
    args = <String, dynamic>{
      "captionText": captionText + "\n" + tags.toString(),
      "url": modifiedUrl,
      "trailingText": trailingText ?? ''
    };
  } else {
    args = <String, dynamic>{
      "captionText": captionText + " ",
      "url": modifiedUrl,
      "trailingText": trailingText ?? ''
    };
  }
  final String? version = await _channel.invokeMethod('shareTwitter', args);
  return version;
}