executeAction method

  1. @override
Future<void> executeAction(
  1. {required BuildContext context,
  2. required WidgetRef ref,
  3. required AppModel appModel,
  4. required CreatorModel creatorModel,
  5. required DictionaryHeading heading,
  6. required String? dictionaryName}
)
override

Execute the functionality of this action.

Implementation

@override
Future<void> executeAction({
  required BuildContext context,
  required WidgetRef ref,
  required AppModel appModel,
  required CreatorModel creatorModel,
  required DictionaryHeading heading,
  required String? dictionaryName,
}) async {
  StringBuffer buffer = StringBuffer();
  buffer.write(heading.term);
  if (heading.reading.isNotEmpty) {
    buffer.write(' (${heading.reading})');
  }
  buffer.write('\n\n');
  buffer.write(
    MeaningField.flattenMeanings(
        entries: heading.entries.toList(),
        prependDictionaryNames:
            appModel.lastSelectedMapping.prependDictionaryNames ?? false),
  );

  String shareText = buffer.toString();

  Share.share(shareText);
}