4
4
5
5
import 'package:flutter/material.dart' ;
6
6
import 'package:flutter_test/flutter_test.dart' ;
7
+
7
8
import '../rendering/mock_canvas.dart' ;
8
9
9
10
void main () {
10
- testWidgets ('Divider control test' , (WidgetTester tester) async {
11
+ testWidgets ('Material3 - Divider control test' , (WidgetTester tester) async {
12
+ await tester.pumpWidget (
13
+ MaterialApp (
14
+ theme: ThemeData (useMaterial3: true ),
15
+ home: const Center (child: Divider ()),
16
+ ),
17
+ );
18
+ final RenderBox box = tester.firstRenderObject (find.byType (Divider ));
19
+ expect (box.size.height, 16.0 );
20
+ final Container container = tester.widget (find.byType (Container ));
21
+ final BoxDecoration decoration = container.decoration! as BoxDecoration ;
22
+ expect (decoration.border! .bottom.width, 1.0 );
23
+ });
24
+
25
+ testWidgets ('Material2 - Divider control test' , (WidgetTester tester) async {
11
26
await tester.pumpWidget (
12
27
MaterialApp (
13
28
theme: ThemeData (useMaterial3: false ),
14
- home: const Center (
15
- child: Divider (),
16
- ),
29
+ home: const Center (child: Divider ()),
17
30
),
18
31
);
19
32
final RenderBox box = tester.firstRenderObject (find.byType (Divider ));
@@ -27,11 +40,7 @@ void main() {
27
40
await tester.pumpWidget (
28
41
const Directionality (
29
42
textDirection: TextDirection .ltr,
30
- child: Center (
31
- child: Divider (
32
- thickness: 5.0 ,
33
- ),
34
- ),
43
+ child: Center (child: Divider (thickness: 5.0 )),
35
44
),
36
45
);
37
46
final Container container = tester.widget (find.byType (Container ));
@@ -47,11 +56,7 @@ void main() {
47
56
await tester.pumpWidget (
48
57
const Directionality (
49
58
textDirection: TextDirection .ltr,
50
- child: Center (
51
- child: Divider (
52
- indent: customIndent,
53
- ),
54
- ),
59
+ child: Center (child: Divider (indent: customIndent)),
55
60
),
56
61
);
57
62
// The divider line is drawn with a DecoratedBox with a border
@@ -63,11 +68,7 @@ void main() {
63
68
await tester.pumpWidget (
64
69
const Directionality (
65
70
textDirection: TextDirection .ltr,
66
- child: Center (
67
- child: Divider (
68
- endIndent: customIndent,
69
- ),
70
- ),
71
+ child: Center (child: Divider (endIndent: customIndent)),
71
72
),
72
73
);
73
74
dividerRect = tester.getRect (find.byType (Divider ));
@@ -92,13 +93,26 @@ void main() {
92
93
expect (lineRect.right, dividerRect.right - customIndent);
93
94
});
94
95
95
- testWidgets ('Vertical Divider Test' , (WidgetTester tester) async {
96
+ testWidgets ('Material3 - Vertical Divider Test' , (WidgetTester tester) async {
97
+ await tester.pumpWidget (
98
+ MaterialApp (
99
+ theme: ThemeData (useMaterial3: true ),
100
+ home: const Center (child: VerticalDivider ()),
101
+ ),
102
+ );
103
+ final RenderBox box = tester.firstRenderObject (find.byType (VerticalDivider ));
104
+ expect (box.size.width, 16.0 );
105
+ final Container container = tester.widget (find.byType (Container ));
106
+ final BoxDecoration decoration = container.decoration! as BoxDecoration ;
107
+ final Border border = decoration.border! as Border ;
108
+ expect (border.left.width, 1.0 );
109
+ });
110
+
111
+ testWidgets ('Material2 - Vertical Divider Test' , (WidgetTester tester) async {
96
112
await tester.pumpWidget (
97
113
MaterialApp (
98
114
theme: ThemeData (useMaterial3: false ),
99
- home: const Center (
100
- child: VerticalDivider (),
101
- ),
115
+ home: const Center (child: VerticalDivider ()),
102
116
),
103
117
);
104
118
final RenderBox box = tester.firstRenderObject (find.byType (VerticalDivider ));
@@ -113,11 +127,7 @@ void main() {
113
127
await tester.pumpWidget (
114
128
const Directionality (
115
129
textDirection: TextDirection .ltr,
116
- child: Center (
117
- child: VerticalDivider (
118
- thickness: 5.0 ,
119
- ),
120
- ),
130
+ child: Center (child: VerticalDivider (thickness: 5.0 )),
121
131
),
122
132
);
123
133
final Container container = tester.widget (find.byType (Container ));
@@ -158,11 +168,7 @@ void main() {
158
168
await tester.pumpWidget (
159
169
const Directionality (
160
170
textDirection: TextDirection .ltr,
161
- child: Center (
162
- child: VerticalDivider (
163
- indent: customIndent,
164
- ),
165
- ),
171
+ child: Center (child: VerticalDivider (indent: customIndent)),
166
172
),
167
173
);
168
174
// The divider line is drawn with a DecoratedBox with a border
@@ -174,11 +180,7 @@ void main() {
174
180
await tester.pumpWidget (
175
181
const Directionality (
176
182
textDirection: TextDirection .ltr,
177
- child: Center (
178
- child: VerticalDivider (
179
- endIndent: customIndent,
180
- ),
181
- ),
183
+ child: Center (child: VerticalDivider (endIndent: customIndent)),
182
184
),
183
185
);
184
186
dividerRect = tester.getRect (find.byType (VerticalDivider ));
0 commit comments