Chore: dart fixes and formatting

pull/2120/head
CatHood0 8 months ago
parent 777477ad0a
commit 95e20d5b05
  1. 7
      flutter_quill_extensions/lib/flutter_quill_extensions.dart
  2. 9
      flutter_quill_extensions/lib/src/editor/spell_checker/simple_spell_checker_service.dart
  3. 3
      lib/src/editor/spellchecker/default_spellchecker_service.dart
  4. 4
      lib/src/editor/spellchecker/spellchecker_service_provider.dart
  5. 4
      lib/src/editor/widgets/text/text_line.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]

@ -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<LanguageIdentifier> {
class SimpleSpellCheckerService
extends SpellCheckerService<LanguageIdentifier> {
SimpleSpellCheckerService({required super.language})
: checker = SimpleSpellChecker(
language: language,
@ -20,11 +21,13 @@ class SimpleSpellCheckerService extends SpellCheckerService<LanguageIdentifier>
@override
List<TextSpan>? checkSpelling(
String text, {
LongPressGestureRecognizer Function(String word)? customLongPressRecognizerOnWrongSpan,
LongPressGestureRecognizer Function(String word)?
customLongPressRecognizerOnWrongSpan,
}) {
return checker.check(
text,
customLongPressRecognizerOnWrongSpan: customLongPressRecognizerOnWrongSpan,
customLongPressRecognizerOnWrongSpan:
customLongPressRecognizerOnWrongSpan,
);
}

@ -14,7 +14,8 @@ class DefaultSpellCheckerService extends SpellCheckerService<Object?> {
@override
List<TextSpan>? checkSpelling(
String text, {
LongPressGestureRecognizer Function(String p1)? customLongPressRecognizerOnWrongSpan,
LongPressGestureRecognizer Function(String p1)?
customLongPressRecognizerOnWrongSpan,
}) {
return null;
}

@ -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);
}

@ -408,8 +408,8 @@ class _TextLineState extends State<TextLine> {
!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,

Loading…
Cancel
Save