childWidget method
Builds the marker's main content widget with appropriate constraints.
Handles special layout cases for centered timelines and ensures proper alignment and sizing of the content.
Implementation
Widget childWidget(BoxConstraints constraints) {
final child = ConstrainedBox(
constraints: BoxConstraints(
minHeight:
properties.iconSize + properties.markerGap + properties.lineWidth,
maxWidth: (
// if timeline is centered, clamp the width to half of
// the screen size excluding the icon size and margin
properties.timelinePosition == TimelinePosition.center
? (constraints.maxWidth / 2 -
properties.iconSize -
properties.iconGap)
: constraints.maxWidth)),
child: data.child,
);
if (properties.timelinePosition == TimelinePosition.center) {
// align child opposite to it's position to make it look aligned around
// the center line
return Align(
alignment: data.position.isLeft()
? Alignment.centerLeft
: Alignment.centerRight,
child: child,
);
}
return child;
}