@@ -1045,6 +1045,79 @@ void main() {
1045
1045
await tester.pumpAndSettle ();
1046
1046
expect (getOverlayColor (tester), paints..rect (color: overlayColor));
1047
1047
});
1048
+
1049
+ // This is a regression test for https://github.com/flutter/flutter/issues/144990.
1050
+ testWidgets ('SegmentedButton clips border path when drawing segments' , (WidgetTester tester) async {
1051
+ await tester.pumpWidget (
1052
+ MaterialApp (
1053
+ home: Scaffold (
1054
+ body: Center (
1055
+ child: SegmentedButton <int >(
1056
+ segments: const < ButtonSegment <int >> [
1057
+ ButtonSegment <int >(
1058
+ value: 0 ,
1059
+ label: Text ('Option 1' ),
1060
+ ),
1061
+ ButtonSegment <int >(
1062
+ value: 1 ,
1063
+ label: Text ('Option 2' ),
1064
+ ),
1065
+ ],
1066
+ onSelectionChanged: (Set <int > selected) {},
1067
+ selected: const < int > {0 },
1068
+ ),
1069
+ ),
1070
+ ),
1071
+ ),
1072
+ );
1073
+
1074
+ expect (
1075
+ find.byType (SegmentedButton <int >),
1076
+ paints
1077
+ ..save ()
1078
+ ..clipPath () // Clip the border.
1079
+ ..path (color: const Color (0xffe8def8 )) // Draw segment 0.
1080
+ ..save ()
1081
+ ..clipPath () // Clip the border.
1082
+ ..path (color: const Color (0x00000000 )), // Draw segment 1.
1083
+ );
1084
+ });
1085
+
1086
+ // This is a regression test for https://github.com/flutter/flutter/issues/144990.
1087
+ testWidgets ('SegmentedButton dividers matches border rect size' , (WidgetTester tester) async {
1088
+ await tester.pumpWidget (
1089
+ MaterialApp (
1090
+ home: Scaffold (
1091
+ body: Center (
1092
+ child: SegmentedButton <int >(
1093
+ segments: const < ButtonSegment <int >> [
1094
+ ButtonSegment <int >(
1095
+ value: 0 ,
1096
+ label: Text ('Option 1' ),
1097
+ ),
1098
+ ButtonSegment <int >(
1099
+ value: 1 ,
1100
+ label: Text ('Option 2' ),
1101
+ ),
1102
+ ],
1103
+ onSelectionChanged: (Set <int > selected) {},
1104
+ selected: const < int > {0 },
1105
+ ),
1106
+ ),
1107
+ ),
1108
+ ),
1109
+ );
1110
+
1111
+ const double tapTargetSize = 48.0 ;
1112
+ expect (
1113
+ find.byType (SegmentedButton <int >),
1114
+ paints
1115
+ ..line (
1116
+ p1: const Offset (166.8000030517578 , 4.0 ),
1117
+ p2: const Offset (166.8000030517578 , tapTargetSize - 4.0 ),
1118
+ ),
1119
+ );
1120
+ });
1048
1121
}
1049
1122
1050
1123
Set <MaterialState > enabled = const < MaterialState > {};
0 commit comments