Skip to content

Commit

Permalink
update lints
Browse files Browse the repository at this point in the history
  • Loading branch information
knaeckeKami committed Dec 30, 2023
1 parent 517c332 commit 294ece3
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Defines a default set of lint rules enforced for
# projects at Google. For details and rationale,
# see https://github.com/dart-lang/pedantic#enabled-lints.
include: package:pedantic/analysis_options.yaml
include: package:lints/recommended.yaml

# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
# Uncomment to specify additional rules.
Expand Down
2 changes: 2 additions & 0 deletions lib/src/model.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: constant_identifier_names

import 'package:collection/collection.dart';

enum TextAlignment {
Expand Down
10 changes: 5 additions & 5 deletions lib/src/table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Table {
final rowSpanCarries = IntCounts();

final positionedCells = <PositionedCell>[];
final _cellTable = <List<PositionedCell?>>[];
final cellTable = <List<PositionedCell?>>[];
var rowIndex = 0;

for (final section
Expand All @@ -36,15 +36,15 @@ class Table {
for (final row in section.rows) {
final rowStyle = sectionStyle + row.cellStyle;
final cellRow = <PositionedCell?>[];
_cellTable.add(cellRow);
cellTable.add(cellRow);
var columnIndex = 0;
var rawColumnIndex = 0;
for (final cell in row.cells) {
// Check for any previous rows' cells whose >1 rowSpan carries them into this row.
// When found, add them to the current row, pushing remaining cells to the right.
while (columnIndex < rowSpanCarries.size &&
rowSpanCarries[columnIndex] > 0) {
cellRow.add(_cellTable[rowIndex - 1][columnIndex]);
cellRow.add(cellTable[rowIndex - 1][columnIndex]);
rowSpanCarries.set(columnIndex, rowSpanCarries[columnIndex] - 1);
columnIndex++;
}
Expand Down Expand Up @@ -74,7 +74,7 @@ class Table {
// When found, add them to the current row, filling any gaps with null.
while (columnIndex < rowSpanCarries.size) {
if (rowSpanCarries[columnIndex] > 0) {
cellRow.add(_cellTable[rowIndex - 1][columnIndex]);
cellRow.add(cellTable[rowIndex - 1][columnIndex]);
rowSpanCarries.set(columnIndex, rowSpanCarries[columnIndex] - 1);
} else {
cellRow.add(null);
Expand All @@ -86,7 +86,7 @@ class Table {
}
columnCount = rowSpanCarries.size;
this.positionedCells = positionedCells;
this._cellTable = _cellTable;
_cellTable = cellTable;
}

PositionedCell? getOrNull(int row, int column) {
Expand Down
5 changes: 3 additions & 2 deletions lib/src/text_border.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: non_constant_identifier_names

import 'package:characters/characters.dart';

class TextBorder {
Expand All @@ -7,10 +9,9 @@ class TextBorder {
return TextBorder.fromCharacters(Characters(string));
}

TextBorder.fromCharacters(Characters characters)
TextBorder.fromCharacters(this.characters)
: assert(characters.length == 16,
'Border string must contain exactly 16 characters, but got ${characters.length}'),
characters = characters,
empty = characters.elementAt(0),
down = characters.elementAt(1),
up = characters.elementAt(2),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/text_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class SimpleLayout implements TextLayout {
/// experimental, does not always behave correctly
@experimental
class EmojiAwareLayout extends SimpleLayout {
EmojiAwareLayout(PositionedCell cell) : super(cell);
EmojiAwareLayout(super.cell);

static const zeroWidthJoiner = '\u200D';

Expand Down
8 changes: 4 additions & 4 deletions lib/src/text_render.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ extension Render on Table {
final commonSize = remainingSize ~/ rowSpan;
final extraSize = remainingSize - (commonSize * rowSpan);
var spanIndex = 0;
rowSpanIndices.forEach((targetRowIndex) {
for (var targetRowIndex in rowSpanIndices) {
final additionalSize =
(spanIndex < extraSize) ? commonSize + 1 : commonSize;
final currentHeight = rowHeights[targetRowIndex];
final newHeight = currentHeight + additionalSize;
rowHeights[targetRowIndex] = newHeight;
spanIndex++;
});
}
}
}

Expand Down Expand Up @@ -289,7 +289,7 @@ extension Render on Table {
}
}

positionedCells.forEach((positionedCell) {
for (var positionedCell in positionedCells) {
final rowIndex = positionedCell.rowIndex;
final columnIndex = positionedCell.columnIndex;
final cell = positionedCell.cell;
Expand All @@ -303,7 +303,7 @@ extension Render on Table {
final canvas = surface.clip(cellLeft, cellRight, cellTop, cellBottom);
final layout = layouts[cell]!;
layout.draw(canvas);
});
}

return surface.toString();
}
Expand Down
5 changes: 2 additions & 3 deletions lib/src/text_surface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ abstract class TextCanvas {
class TextSurface extends TextCanvas {
final List<String> rowBuilders;

TextSurface(int width, int height)
TextSurface(super.width, super.height)
: rowBuilders =
List.filled(height, [for (int i = 0; i < width; i++) ' '].join('')),
super(width, height);
List.filled(height, [for (int i = 0; i < width; i++) ' '].join(''));

@override
void setCharacter(int? row, int? column, Characters unicodeChar) {
Expand Down
2 changes: 1 addition & 1 deletion test/text_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ void main() {
// 3 UTF-8 bytes, full-width.
expect(2, '\u5317a'.visualCodePointCount);
// 4 UTF-8 bytes (2 * UTF-16), full-width.
expect(2, (String.fromCharCode(0x1F603) + 'a').visualCodePointCount);
expect(2, ('${String.fromCharCode(0x1F603)}a').visualCodePointCount);
});
}

0 comments on commit 294ece3

Please sign in to comment.