share function

Future<void> share(
  1. {String? text,
  2. String? title,
  3. List<String> files = const []}
)

Share text and files with external applications.

You can specify the subject by entering title.

Implementation

Future<void> share({
  String? text,
  String? title,
  List<String> files = const [],
}) async {
  if (files.isNotEmpty) {
    await Share.shareFiles(files, subject: title, text: text);
  } else {
    assert(text.isNotEmpty, "Text is empty.");
    await Share.share(text ?? "", subject: title);
  }
}