padTopBottom method
Adds padding to the top and bottom of the matrix.
This method inserts blank lines at the top and bottom of the matrix data, effectively adding padding to the matrix.
Parameters:
paddingTop
: The number of blank lines to add at the top of the matrix.paddingBottom
: The number of blank lines to add at the bottom of the matrix.
The method modifies the matrix in place by:
- Creating blank lines (rows filled with
false
values). - Inserting the specified number of blank lines at the top of the matrix.
- Appending the specified number of blank lines at the bottom of the matrix.
- Updating the total number of rows in the matrix.
Implementation
void padTopBottom({
required final int paddingTop,
required final int paddingBottom,
}) {
final blankLine = List.filled(cols, false);
for (int add = 0; add < paddingTop; add++) {
this._data.insert(0, blankLine);
}
for (int add = 0; add < paddingBottom; add++) {
this._data.add(blankLine);
}
this.rows = _data.length;
}