checkSpelling method

  1. @override
Future<List<WordMatch>> checkSpelling(
  1. String text
)
override

Implementation

@override
Future<List<WordMatch>> checkSpelling(String text) async {
  final List<dynamic> suggestions =
      await methodChannel.invokeMethod('checkSpelling', {'text': text});

  return suggestions.map((e) {
    final result = Map<String, dynamic>.from(e);
    final word = result['word'] as String;
    final offset = text.indexOf(word) + 1;
    result['offset'] = offset;
    result['length'] = word.length;
    result['sentence'] = text;
    result['message'] = 'Possible spelling mistake found.';

    return WordMatch.fromJson(result);
  }).toList();
}