Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency Updates #15

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
include: package:pedantic/analysis_options.yaml
include: package:flutter_lints/flutter.yaml
analyzer:
strong-mode:
implicit-casts: false
errors:
dead_code: error
unused_element: error
Expand All @@ -15,7 +13,6 @@ linter:
# - always_put_required_named_parameters_first
- always_put_control_body_on_new_line
- always_put_required_named_parameters_first
- always_require_non_null_named_parameters
- annotate_overrides
- avoid_annotating_with_dynamic
# - avoid_as
Expand All @@ -40,8 +37,6 @@ linter:
- avoid_relative_lib_imports
- avoid_renaming_method_parameters
- avoid_return_types_on_setters
- avoid_returning_null
- avoid_returning_null_for_future
- avoid_returning_null_for_void
- avoid_returning_this
# - avoid_setters_without_getters
Expand Down Expand Up @@ -76,13 +71,11 @@ linter:
- hash_and_equals
- implementation_imports
- invariant_booleans
- iterable_contains_unrelated_type
- join_return_with_assignment
- leading_newlines_in_multiline_strings
- library_names
- library_prefixes
- lines_longer_than_80_chars
- list_remove_unrelated_type
# - literal_only_boolean_expressions
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
Expand Down
11 changes: 8 additions & 3 deletions lib/src/delta_markdown_decoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,22 @@ class _DeltaVisitor implements ast.NodeVisitor {
final href = el.attributes['src'];
return ImageAttribute(href);
case 'hr':
return DividerAttribute();
return const DividerAttribute();
}

return null;
}
}

class ImageAttribute extends Attribute<String?> {
ImageAttribute(String? val) : super('image', AttributeScope.EMBEDS, val);
const ImageAttribute(String? val)
: super(
'image',
AttributeScope.embeds,
val,
);
}

class DividerAttribute extends Attribute<String?> {
DividerAttribute() : super('divider', AttributeScope.EMBEDS, 'hr');
const DividerAttribute() : super('divider', AttributeScope.embeds, 'hr');
}
8 changes: 4 additions & 4 deletions lib/src/delta_markdown_encoder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DeltaMarkdownEncoder extends Converter<String, String> {
String convert(String input) {
markdownBuffer = StringBuffer();
lineBuffer = StringBuffer();
currentInlineStyle = Style();
currentInlineStyle = const Style();
currentBlockLines = <String>[];

final inputJson = jsonDecode(input) as List<dynamic>?;
Expand Down Expand Up @@ -66,7 +66,7 @@ class DeltaMarkdownEncoder extends Converter<String, String> {
for (final value
in currentInlineStyle.attributes.values.toList().reversed) {
// TODO(tillf): Is block correct?
if (value.scope == AttributeScope.BLOCK) {
if (value.scope == AttributeScope.block) {
continue;
}
if (style.containsKey(value.key)) {
Expand All @@ -89,7 +89,7 @@ class DeltaMarkdownEncoder extends Converter<String, String> {
// Now open any new styles.
for (final attribute in style.attributes.values) {
// TODO(tillf): Is block correct?
if (attribute.scope == AttributeScope.BLOCK) {
if (attribute.scope == AttributeScope.block) {
continue;
}
if (currentInlineStyle.containsKey(attribute.key)) {
Expand Down Expand Up @@ -124,7 +124,7 @@ class DeltaMarkdownEncoder extends Converter<String, String> {
final lineBlock = Style.fromJson(attributes)
.attributes
.values
.singleWhereOrNull((a) => a.scope == AttributeScope.BLOCK);
.singleWhereOrNull((a) => a.scope == AttributeScope.block);

if (lineBlock == currentBlockStyle) {
currentBlockLines.add(lineBuffer.toString());
Expand Down
19 changes: 9 additions & 10 deletions lib/src/inline_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ class AutolinkExtensionSyntax extends InlineSyntax {
}
}

class _DelimiterRun {
_DelimiterRun._(
class DelimiterRun {
DelimiterRun._(
{this.char,
this.length,
this.isLeftFlanking,
Expand All @@ -420,8 +420,7 @@ class _DelimiterRun {
final bool? isFollowedByPunctuation;

// ignore: prefer_constructors_over_static_methods
static _DelimiterRun? tryParse(
InlineParser parser, int runStart, int runEnd) {
static DelimiterRun? tryParse(InlineParser parser, int runStart, int runEnd) {
bool leftFlanking,
rightFlanking,
precededByPunctuation,
Expand Down Expand Up @@ -466,7 +465,7 @@ class _DelimiterRun {
return null;
}

return _DelimiterRun._(
return DelimiterRun._(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Satisfying Dart analysis

char: parser.charAt(runStart),
length: runEnd - runStart + 1,
isLeftFlanking: leftFlanking,
Expand Down Expand Up @@ -516,7 +515,7 @@ class TagSyntax extends InlineSyntax {
return true;
}

final delimiterRun = _DelimiterRun.tryParse(parser, matchStart, matchEnd);
final delimiterRun = DelimiterRun.tryParse(parser, matchStart, matchEnd);
if (delimiterRun != null && delimiterRun.canOpen) {
parser.openTag(TagState(parser.pos, matchEnd + 1, this, delimiterRun));
return true;
Expand All @@ -531,7 +530,7 @@ class TagSyntax extends InlineSyntax {
final matchStart = parser.pos;
final matchEnd = parser.pos + runLength - 1;
final openingRunLength = state.endPos - state.startPos;
final delimiterRun = _DelimiterRun.tryParse(parser, matchStart, matchEnd);
final delimiterRun = DelimiterRun.tryParse(parser, matchStart, matchEnd);

if (openingRunLength == 1 && runLength == 1) {
parser.addNode(Element('em', state.children));
Expand Down Expand Up @@ -579,7 +578,7 @@ class StrikethroughSyntax extends TagSyntax {
final runLength = match.group(0)!.length;
final matchStart = parser.pos;
final matchEnd = parser.pos + runLength - 1;
final delimiterRun = _DelimiterRun.tryParse(parser, matchStart, matchEnd)!;
final delimiterRun = DelimiterRun.tryParse(parser, matchStart, matchEnd)!;
if (!delimiterRun.isRightFlanking!) {
return false;
}
Expand Down Expand Up @@ -1170,7 +1169,7 @@ class TagState {
/// The children of this node. Will be `null` for text nodes.
final List<Node> children;

final _DelimiterRun? openingDelimiterRun;
final DelimiterRun? openingDelimiterRun;

/// Attempts to close this tag by matching the current text against its end
/// pattern.
Expand All @@ -1193,7 +1192,7 @@ class TagState {
final closingMatchStart = parser.pos;
final closingMatchEnd = parser.pos + runLength - 1;
final closingDelimiterRun =
_DelimiterRun.tryParse(parser, closingMatchStart, closingMatchEnd);
DelimiterRun.tryParse(parser, closingMatchStart, closingMatchEnd);
if (closingDelimiterRun != null && closingDelimiterRun.canClose) {
// Emphasis rules #9 and #10:
final oneRunOpensAndCloses =
Expand Down
14 changes: 7 additions & 7 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ environment:
sdk: ">=2.12.0 <3.0.0"

dependencies:
args: ^2.0.0
charcode: ^1.2.0
collection: ^1.15.0
flutter_quill: ^7.0.0
args: ^2.4.2
charcode: ^1.3.1
collection: ^1.17.2
flutter_quill: ^8.2.5

dev_dependencies:
build_runner: ^2.0.0
build_runner: ^2.4.6
flutter_lints: ^3.0.1
flutter_test:
sdk: flutter
pedantic: ^1.11.0
test: ^1.16.5
test: ^1.24.3