generateIndentationRulers method
List<Row>
generateIndentationRulers(
)
Implementation
List<Row> generateIndentationRulers() {
final List<Row> rows = [];
// this flag allows a single indentation ruler to be added to the
// start of lines inside a nested code snippet, such as a function body, even
// if they are empty lines
bool isNested = false;
for (final line in textController.text.split('\n')) {
// create an initial Row
final List<Widget> rowItems = [Text('', style: codeTextStyle)];
// only trigger the loop if there is a possbility of indentation
if (line.startsWith(' ')) {
isNested = true;
for (int i = 0; i < line.length; i++) {
if (line[i] == ' ') {
// add an indentation ruler at every tab
if (i %
widget.api.workspace.workspaceConfigs.stylingConfigs
.tabSizeInSpaces ==
0) {
rowItems.add(
Container(
decoration: BoxDecoration(
border: Border(
left: BorderSide(
width: 0.5,
color: widget.api.workspace.workspaceConfigs.themeBundle
.editorTheme.editorIndentGuideBackground1 ??
Colors.red,
),
),
),
child: SizedBox(
width: cellWidth *
widget.api.workspace.workspaceConfigs.stylingConfigs
.tabSizeInSpaces,
height: cellHeight),
),
);
}
} else {
break;
}
}
} else {
isNested = false;
}
rows.add(
Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: line.trim() == '' && !isNested
? [
SizedBox(
width: 0,
height: cellHeight,
)
]
: rowItems,
),
);
}
return rows;
}