diff --git a/flutter_quill_extensions/lib/flutter_quill_extensions.dart b/flutter_quill_extensions/lib/flutter_quill_extensions.dart index dba74bd3..e8a499ca 100644 --- a/flutter_quill_extensions/lib/flutter_quill_extensions.dart +++ b/flutter_quill_extensions/lib/flutter_quill_extensions.dart @@ -1,7 +1,7 @@ library flutter_quill_extensions; // ignore: implementation_imports -import 'package:flutter_quill/flutter_quill.dart'; +import 'package:flutter_quill/src/editor/spellchecker/spellchecker_service_provider.dart'; import 'package:flutter_quill/src/editor_toolbar_controller_shared/clipboard/clipboard_service_provider.dart'; import 'package:meta/meta.dart' show immutable; @@ -45,7 +45,7 @@ class FlutterQuillExtensions { /// override the default implementation of [SpellCheckerServiceProvider] /// to allow a `flutter quill` support a better check spelling /// - /// # !WARNING + /// # !WARNING /// To avoid memory leaks, ensure to use [dispose()] method to /// close stream controllers that used by this custom implementation /// when them no longer needed @@ -57,7 +57,8 @@ class FlutterQuillExtensions { ///SpellCheckerServiceProvider.dispose(onlyPartial: false); ///``` static void useSpellCheckerService(String language) { - SpellCheckerServiceProvider.setNewCheckerService(SimpleSpellCheckerService(language: language)); + SpellCheckerServiceProvider.setNewCheckerService( + SimpleSpellCheckerService(language: language)); } /// Override default implementation of [ClipboardServiceProvider.instance] diff --git a/flutter_quill_extensions/lib/src/editor/spell_checker/simple_spell_checker_service.dart b/flutter_quill_extensions/lib/src/editor/spell_checker/simple_spell_checker_service.dart index 70dccfc0..fe36678b 100644 --- a/flutter_quill_extensions/lib/src/editor/spell_checker/simple_spell_checker_service.dart +++ b/flutter_quill_extensions/lib/src/editor/spell_checker/simple_spell_checker_service.dart @@ -5,7 +5,8 @@ import 'package:simple_spell_checker/simple_spell_checker.dart'; /// SimpleSpellChecker is a simple spell checker for get /// all words divide on different objects if them are wrong or not -class SimpleSpellCheckerService extends SpellCheckerService { +class SimpleSpellCheckerService + extends SpellCheckerService { SimpleSpellCheckerService({required super.language}) : checker = SimpleSpellChecker( language: language, @@ -20,11 +21,13 @@ class SimpleSpellCheckerService extends SpellCheckerService @override List? checkSpelling( String text, { - LongPressGestureRecognizer Function(String word)? customLongPressRecognizerOnWrongSpan, + LongPressGestureRecognizer Function(String word)? + customLongPressRecognizerOnWrongSpan, }) { return checker.check( text, - customLongPressRecognizerOnWrongSpan: customLongPressRecognizerOnWrongSpan, + customLongPressRecognizerOnWrongSpan: + customLongPressRecognizerOnWrongSpan, ); } diff --git a/lib/src/editor/spellchecker/default_spellchecker_service.dart b/lib/src/editor/spellchecker/default_spellchecker_service.dart index 7dcb3a25..cfeb1a12 100644 --- a/lib/src/editor/spellchecker/default_spellchecker_service.dart +++ b/lib/src/editor/spellchecker/default_spellchecker_service.dart @@ -14,7 +14,8 @@ class DefaultSpellCheckerService extends SpellCheckerService { @override List? checkSpelling( String text, { - LongPressGestureRecognizer Function(String p1)? customLongPressRecognizerOnWrongSpan, + LongPressGestureRecognizer Function(String p1)? + customLongPressRecognizerOnWrongSpan, }) { return null; } diff --git a/lib/src/editor/spellchecker/spellchecker_service_provider.dart b/lib/src/editor/spellchecker/spellchecker_service_provider.dart index 47bd4771..24a51ebf 100644 --- a/lib/src/editor/spellchecker/spellchecker_service_provider.dart +++ b/lib/src/editor/spellchecker/spellchecker_service_provider.dart @@ -13,11 +13,11 @@ class SpellCheckerServiceProvider { _instance = service; } - static void dispose({bool onlyPartial = false}){ + static void dispose({bool onlyPartial = false}) { _instance.dispose(onlyPartial: onlyPartial); } - static void setNewLanguageState({required String language}){ + static void setNewLanguageState({required String language}) { assert(language.isNotEmpty); _instance.setNewLanguageState(language: language); } diff --git a/lib/src/editor/widgets/text/text_line.dart b/lib/src/editor/widgets/text/text_line.dart index f1f30b2e..7c4f3c07 100644 --- a/lib/src/editor/widgets/text/text_line.dart +++ b/lib/src/editor/widgets/text/text_line.dart @@ -408,8 +408,8 @@ class _TextLineState extends State { !widget.readOnly && !widget.line.style.attributes.containsKey('code-block') && !kIsWeb) { - final service = SpellcheckerServiceProvider.instance; - final spellcheckedSpans = service.fetchSpellchecker(textNode.value); + final service = SpellCheckerServiceProvider.instance; + final spellcheckedSpans = service.checkSpelling(textNode.value); if (spellcheckedSpans != null && spellcheckedSpans.isNotEmpty) { return TextSpan( children: spellcheckedSpans,