parent
b4c9d84fd4
commit
dc1a58cd68
7 changed files with 55 additions and 11 deletions
@ -1,11 +1,17 @@ |
||||
import 'package:flutter/material.dart'; |
||||
import 'spellchecker_service.dart'; |
||||
import 'package:flutter/gestures.dart' show LongPressGestureRecognizer; |
||||
import 'package:flutter/material.dart' show TextSpan; |
||||
import 'spellchecker_service.dart' show SpellcheckerService; |
||||
|
||||
class DefaultSpellcheckerService extends SpellcheckerService{ |
||||
class DefaultSpellcheckerService extends SpellcheckerService { |
||||
DefaultSpellcheckerService() : super(language: 'en'); |
||||
|
||||
@override |
||||
List<TextSpan>? fetchSpellchecker(String text) { |
||||
void dispose() {} |
||||
|
||||
@override |
||||
List<TextSpan>? fetchSpellchecker(String text, |
||||
{LongPressGestureRecognizer Function(String p1)? |
||||
customLongPressRecognizerOnWrongSpan}) { |
||||
return null; |
||||
} |
||||
} |
||||
|
@ -1,13 +1,32 @@ |
||||
import 'package:flutter/gestures.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:simple_spell_checker/simple_spell_checker.dart'; |
||||
|
||||
import 'spellchecker_service.dart'; |
||||
|
||||
class SimpleSpellCheckerImpl extends SpellcheckerService { |
||||
SimpleSpellCheckerImpl({required super.language}); |
||||
SimpleSpellCheckerImpl({required super.language}) |
||||
: checker = SimpleSpellChecker( |
||||
language: language, |
||||
safeDictionaryLoad: true, |
||||
); |
||||
final SimpleSpellChecker checker; |
||||
|
||||
@override |
||||
List<TextSpan>? fetchSpellchecker(String text) { |
||||
return null; |
||||
List<TextSpan>? fetchSpellchecker( |
||||
String text, { |
||||
LongPressGestureRecognizer Function(String word)? |
||||
customLongPressRecognizerOnWrongSpan, |
||||
}) { |
||||
return checker.check( |
||||
text, |
||||
customLongPressRecognizerOnWrongSpan: |
||||
customLongPressRecognizerOnWrongSpan, |
||||
); |
||||
} |
||||
|
||||
@override |
||||
void dispose() { |
||||
checker.dispose(closeDirectionary: true); |
||||
} |
||||
} |
||||
|
@ -1,8 +1,13 @@ |
||||
import 'package:flutter/gestures.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
|
||||
abstract class SpellcheckerService { |
||||
SpellcheckerService({required this.language}); |
||||
|
||||
final String language; |
||||
List<TextSpan>? fetchSpellchecker(String text); |
||||
|
||||
void dispose(); |
||||
List<TextSpan>? fetchSpellchecker(String text, |
||||
{LongPressGestureRecognizer Function(String)? |
||||
customLongPressRecognizerOnWrongSpan}); |
||||
} |
||||
|
Loading…
Reference in new issue