@@ -1013,7 +1013,13 @@ class _RenderSegmentedControl<T extends Object> extends RenderBox
1013
1013
return maxHeight;
1014
1014
}
1015
1015
1016
- List <double > _getChildIntrinsicWidths (BoxConstraints constraints) {
1016
+ List <double > _getChildWidths (BoxConstraints constraints) {
1017
+ if (! proportionalWidth) {
1018
+ final double maxChildWidth = _getMaxChildWidth (constraints);
1019
+ final int segmentCount = childCount ~ / 2 + 1 ;
1020
+ return List <double >.filled (segmentCount, maxChildWidth);
1021
+ }
1022
+
1017
1023
final List <double > segmentWidths = < double > [];
1018
1024
RenderBox ? child = firstChild;
1019
1025
while (child != null ) {
@@ -1043,12 +1049,7 @@ class _RenderSegmentedControl<T extends Object> extends RenderBox
1043
1049
1044
1050
Size _computeOverallSize (BoxConstraints constraints) {
1045
1051
final double maxChildHeight = _getMaxChildHeight (constraints, constraints.maxWidth);
1046
- if (proportionalWidth) {
1047
- return constraints.constrain (Size (_getChildIntrinsicWidths (constraints).sum + totalSeparatorWidth, maxChildHeight));
1048
- }
1049
- final int childCount = this .childCount ~ / 2 + 1 ;
1050
- final double maxChildWidth = _getMaxChildWidth (constraints);
1051
- return constraints.constrain (Size (maxChildWidth * childCount + totalSeparatorWidth, maxChildHeight));
1052
+ return constraints.constrain (Size (_getChildWidths (constraints).sum + totalSeparatorWidth, maxChildHeight));
1052
1053
}
1053
1054
1054
1055
@override
@@ -1071,13 +1072,7 @@ class _RenderSegmentedControl<T extends Object> extends RenderBox
1071
1072
@override
1072
1073
void performLayout () {
1073
1074
final BoxConstraints constraints = this .constraints;
1074
-
1075
- if (proportionalWidth) {
1076
- segmentWidths = _getChildIntrinsicWidths (constraints);
1077
- } else {
1078
- final Size childSize = _calculateChildSize (constraints);
1079
- segmentWidths = List <double >.filled (childCount, childSize.width);
1080
- }
1075
+ segmentWidths = _getChildWidths (constraints);
1081
1076
1082
1077
final double childHeight = _getMaxChildHeight (constraints, double .infinity);
1083
1078
final BoxConstraints separatorConstraints = BoxConstraints (minHeight: childHeight, maxHeight: childHeight);
0 commit comments