Skip to content

Commit 3465758

Browse files
committed
fixed small string centered
1 parent 3de24d8 commit 3465758

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

lib/badge_animation/ani_fixed.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@ class FixedAnimation extends BadgeAnimation {
66
List<List<bool>> processGrid, List<List<bool>> canvas) {
77
int newGridHeight = processGrid.length;
88
int newGridWidth = processGrid[0].length;
9-
const int startCol = 0;
9+
10+
int horizontalOffset = 0;
11+
if (newGridWidth < badgeWidth) {
12+
horizontalOffset = (badgeWidth - newGridWidth) ~/ 2;
13+
}
1014

1115
for (int i = 0; i < badgeHeight; i++) {
1216
for (int j = 0; j < badgeWidth; j++) {
13-
bool isNewGridCell = i < newGridHeight && (startCol + j) < newGridWidth;
17+
int sourceCol = j - horizontalOffset;
18+
19+
bool isWithinNewGrid =
20+
i < newGridHeight && sourceCol >= 0 && sourceCol < newGridWidth;
21+
1422
bool animationCondition =
15-
(isNewGridCell && processGrid[i][startCol + j]);
23+
(isWithinNewGrid && processGrid[i][sourceCol]);
1624

1725
canvas[i][j] = animationCondition;
1826
}

0 commit comments

Comments
 (0)