shareFileToTwitter method

Future shareFileToTwitter({
  1. required String? filePath,
  2. required String fileProviderPath,
  3. required AssetType fileType,
  4. String? dstPath,
  5. String? iOSConsumerKey,
  6. String? iOSSecretKey,
  7. String? title,
})

Share local file to Twitter platform.

The method required a local video file path (filePath), a custom file provider path (fileProviderPath => use on Android platform) and a fileType that you want to share. Besides, you can provide a dstPath (use on Android platform) to add a custom save folder path to cache the local file, title to set the message when sharing the file on Android and iOS platforms, etc.

Only AssetType.video and AssetType.image are supported.

NOTE: If your app support iOS platform please provide the consumer iOSConsumerKey and secret key iOSSecretKey of your app on Twitter developer page

Working on: Android and iOS platforms.

Implementation

Future<dynamic> shareFileToTwitter({
  required String? filePath,
  required String fileProviderPath,
  required AssetType fileType,
  String? dstPath,
  String? iOSConsumerKey,
  String? iOSSecretKey,
  String? title,
}) async {
  if (Platform.isIOS) return;
  assert(
    fileType == AssetType.video || fileType == AssetType.image,
    "Only video and image types are supported",
  );

  return _channel.invokeMethod(
    'shareFileTwitter',
    <String, dynamic>{
      'filePath': filePath,
      'fileProviderPath': fileProviderPath,
      'dstPath': dstPath,
      'fileType': fileType.name,
      'iOSConsumerKey': iOSConsumerKey,
      'iOSSecretKey': iOSSecretKey,
      'title': title,
    },
  );
}