layout method
Implementation
@override
void layout(BoxConstraints constraints) {
super.layout(constraints);
final maxWidth =
width ??
(constraints.hasBoundedWidth
? constraints.maxWidth.round()
: controller.model.width);
final boundedHeight = constraints.hasBoundedHeight
? constraints.maxHeight.round()
: null;
final viewportHeight = height ?? boundedHeight;
final layoutHeight =
viewportHeight ??
controller.model.height ??
controller.model.lines.length;
var contentWidth = math.max(0, maxWidth);
var totalWidth = contentWidth;
_effectiveScrollbar =
showScrollbar && maxWidth > scrollbarSeparator.length + 1;
if (_effectiveScrollbar) {
contentWidth = math.max(1, maxWidth - scrollbarSeparator.length - 1);
totalWidth = contentWidth + scrollbarSeparator.length + 1;
}
controller.setSize(contentWidth, viewportHeight);
size = constraints.constrain(
Size(totalWidth.toDouble(), layoutHeight.toDouble()),
);
}