openTextSegmentationDialog method

Future<void> openTextSegmentationDialog(
  1. {required String sourceText,
  2. List<String>? segmentedText,
  3. dynamic onSelect(
    1. JidoujishoTextSelection
    )?,
  4. dynamic onSearch(
    1. JidoujishoTextSelection
    )?}
)

A helper function for opening a text segmentation dialog.

Implementation

Future<void> openTextSegmentationDialog({
  required String sourceText,
  List<String>? segmentedText,
  Function(JidoujishoTextSelection)? onSelect,
  Function(JidoujishoTextSelection)? onSearch,
}) async {
  if (sourceText.trim().isEmpty) {
    return;
  }

  segmentedText ??= targetLanguage.textToWords(sourceText);

  await showDialog(
    context: _navigatorKey.currentContext!,
    builder: (context) => TextSegmentationDialogPage(
      sourceText: sourceText,
      segmentedText: segmentedText!,
      onSelect: onSelect,
      onSearch: onSearch,
    ),
  );
}