MatrixNode constructor
MatrixNode({
- double arrayStretch = 1.0,
- bool hskipBeforeAndAfter = false,
- bool isSmall = false,
- List<
MatrixColumnAlign> columnAligns = const [], - List<
MatrixSeparatorStyle> vLines = const [], - List<
Measurement> rowSpacings = const [], - List<
MatrixSeparatorStyle> hLines = const [], - required List<
List< body,EquationRowNode?> >
Factory constructor for MatrixNode that will sanitize inputs.
Implementation
factory MatrixNode({
double arrayStretch = 1.0,
bool hskipBeforeAndAfter = false,
bool isSmall = false,
List<MatrixColumnAlign> columnAligns = const [],
List<MatrixSeparatorStyle> vLines = const [],
List<Measurement> rowSpacings = const [],
List<MatrixSeparatorStyle> hLines = const [],
required List<List<EquationRowNode?>> body,
}) {
final cols = max3(
body.map((row) => row.length).maxOrNull ?? 0,
columnAligns.length,
vLines.length - 1,
);
final sanitizedColumnAligns =
columnAligns.extendToByFill(cols, MatrixColumnAlign.center);
final sanitizedVLines =
vLines.extendToByFill(cols + 1, MatrixSeparatorStyle.none);
final rows = max3(
body.length,
rowSpacings.length,
hLines.length - 1,
);
final sanitizedBody = body
.map((row) => row.extendToByFill(cols, null))
.toList(growable: false)
.extendToByFill(rows, List.filled(cols, null));
final sanitizedRowSpacing =
rowSpacings.extendToByFill(rows, Measurement.zero);
final sanitizedHLines =
hLines.extendToByFill(rows + 1, MatrixSeparatorStyle.none);
return MatrixNode._(
rows: rows,
cols: cols,
arrayStretch: arrayStretch,
hskipBeforeAndAfter: hskipBeforeAndAfter,
isSmall: isSmall,
columnAligns: sanitizedColumnAligns,
vLines: sanitizedVLines,
rowSpacings: sanitizedRowSpacing,
hLines: sanitizedHLines,
body: sanitizedBody,
);
}