Skip to content

Commit

Permalink
Document public members, where it is necessary (#13)
Browse files Browse the repository at this point in the history
* Document public members, where it is necessary

* Fix after review

* Fix after review

* Fix after review

* Fix after review
  • Loading branch information
Luxorum committed Apr 25, 2023
1 parent 90ba312 commit 5ca884f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/domain/language_check_service.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import 'package:languagetool_textfield/domain/mistake.dart';

/// A base language check service.
abstract class LanguageCheckService {
/// Creates a new instance of the [LanguageCheckService] class.
const LanguageCheckService();

/// Returns found mistakes in the given [text].
Future<List<Mistake>> findMistakes(String text);
}
13 changes: 13 additions & 0 deletions lib/domain/mistake.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
/// A data model class that stores information about a single writing mistake.
class Mistake {
/// A brief description of the mistake.
final String message;

/// A type of this mistake.
final String type;

/// A position of the beginning of this mistake.
final int offset;

/// A length of this mistake after the offset.
final int length;

/// A list of suggestions for replacing this mistake.
///
/// Sorted by probability.
final List<String> replacements;

/// Creates a new instance of the [Mistake] class.
const Mistake({
required this.message,
required this.type,
Expand Down
5 changes: 5 additions & 0 deletions lib/implementations/debounce_lang_tool_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ import 'package:languagetool_textfield/domain/language_check_service.dart';
import 'package:languagetool_textfield/domain/mistake.dart';
import 'package:throttling/throttling.dart';

/// A language check service with debouncing.
class DebounceLangToolService extends LanguageCheckService {
/// A base language check service.
final LanguageCheckService baseService;

/// A debouncing used to debounce the API calls.
final Debouncing debouncing;

/// Creates a new instance of the [DebounceLangToolService] class.
DebounceLangToolService(
this.baseService,
Duration debouncingDuration,
Expand Down
3 changes: 3 additions & 0 deletions lib/implementations/lang_tool_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import 'package:language_tool/language_tool.dart';
import 'package:languagetool_textfield/domain/language_check_service.dart';
import 'package:languagetool_textfield/domain/mistake.dart';

/// An implementation of language check service with language tool service.
class LangToolService extends LanguageCheckService {
/// An instance of this class that is used to interact with LanguageTool API.
final LanguageTool languageTool;

/// Creates a new instance of the [LangToolService].
const LangToolService(this.languageTool);

@override
Expand Down
6 changes: 6 additions & 0 deletions lib/implementations/throttling_lang_tool_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@ import 'package:languagetool_textfield/domain/language_check_service.dart';
import 'package:languagetool_textfield/domain/mistake.dart';
import 'package:throttling/throttling.dart';

/// A language check service with debouncing.
class ThrottlingLangToolService extends LanguageCheckService {
/// A base language check service that is used to interact
/// with the language check API.
final LanguageCheckService baseService;

/// A throttling used to throttle the API calls.
final Throttling throttling;

/// Creates a new instance of the [ThrottlingLangToolService] class.
ThrottlingLangToolService(
this.baseService,
Duration throttlingDuration,
Expand Down
9 changes: 9 additions & 0 deletions lib/presentation/language_tool_text_field.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import 'package:flutter/material.dart';
import 'package:languagetool_textfield/domain/language_check_service.dart';

/// A TextField widget that checks the grammar using the given [langService]
class LanguageToolTextField extends StatefulWidget {
/// A service for checking errors.
final LanguageCheckService langService;

/// A style to use for the text being edited.
final TextStyle style;

/// A decoration of this [TextField].
final InputDecoration decoration;

/// A builder function used to build errors.
final Widget Function()? mistakeBuilder;

/// Creates a widget that checks grammar errors.
const LanguageToolTextField({
Key? key,
required this.langService,
Expand Down

0 comments on commit 5ca884f

Please sign in to comment.