1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
void main() {
testWidgets('OverflowEntries context contains Overlay',
(WidgetTester tester) async {
final GlobalKey overlayKey = new GlobalKey();
bool didBuild = false;
await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new Overlay(
key: overlayKey,
initialEntries: <OverlayEntry>[
new OverlayEntry(
builder: (BuildContext context) {
didBuild = true;
final Overlay overlay = context.ancestorWidgetOfExactType(Overlay);
expect(overlay, isNotNull);
expect(overlay.key, equals(overlayKey));
return new Container();
},
),
],
),
),
);
expect(didBuild, isTrue);
final RenderObject theater = overlayKey.currentContext.findRenderObject();
expect(theater, hasAGoodToStringDeep);
expect(
theater.toStringDeep(minLevel: DiagnosticLevel.info),
equalsIgnoringHashCodes(
'_RenderTheatre#f5cf2\n'
' │ parentData: <none>\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n'
' │\n'
' ├─onstage: RenderStack#39819\n'
' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0) (can use\n'
' ╎ │ size)\n'
' ╎ │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' ╎ │ size: Size(800.0, 600.0)\n'
' ╎ │ alignment: AlignmentDirectional.topStart\n'
' ╎ │ textDirection: ltr\n'
' ╎ │ fit: expand\n'
' ╎ │ overflow: clip\n'
' ╎ │\n'
' ╎ └─child 1: RenderLimitedBox#d1448\n'
' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0) (can use\n'
' ╎ │ size)\n'
' ╎ │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' ╎ │ size: Size(800.0, 600.0)\n'
' ╎ │ maxWidth: 0.0\n'
' ╎ │ maxHeight: 0.0\n'
' ╎ │\n'
' ╎ └─child: RenderConstrainedBox#e8b87\n'
' ╎ parentData: <none> (can use size)\n'
' ╎ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' ╎ size: Size(800.0, 600.0)\n'
' ╎ additionalConstraints: BoxConstraints(biggest)\n'
' ╎\n'
' └╌no offstage children\n'
),
);
});
testWidgets('Offstage overlay', (WidgetTester tester) async {
final GlobalKey overlayKey = new GlobalKey();
await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.ltr,
child: new Overlay(
key: overlayKey,
initialEntries: <OverlayEntry>[
new OverlayEntry(
opaque: true,
maintainState: true,
builder: (BuildContext context) => new Container(),
),
new OverlayEntry(
opaque: true,
maintainState: true,
builder: (BuildContext context) => new Container(),
),
new OverlayEntry(
opaque: true,
maintainState: true,
builder: (BuildContext context) => new Container(),
),
],
),
),
);
final RenderObject theater = overlayKey.currentContext.findRenderObject();
expect(theater, hasAGoodToStringDeep);
expect(
theater.toStringDeep(minLevel: DiagnosticLevel.info),
equalsIgnoringHashCodes(
'_RenderTheatre#b22a8\n'
' │ parentData: <none>\n'
' │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' │ size: Size(800.0, 600.0)\n'
' │\n'
' ├─onstage: RenderStack#eab87\n'
' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0) (can use\n'
' ╎ │ size)\n'
' ╎ │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' ╎ │ size: Size(800.0, 600.0)\n'
' ╎ │ alignment: AlignmentDirectional.topStart\n'
' ╎ │ textDirection: ltr\n'
' ╎ │ fit: expand\n'
' ╎ │ overflow: clip\n'
' ╎ │\n'
' ╎ └─child 1: RenderLimitedBox#ca15b\n'
' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0) (can use\n'
' ╎ │ size)\n'
' ╎ │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' ╎ │ size: Size(800.0, 600.0)\n'
' ╎ │ maxWidth: 0.0\n'
' ╎ │ maxHeight: 0.0\n'
' ╎ │\n'
' ╎ └─child: RenderConstrainedBox#dffe5\n'
' ╎ parentData: <none> (can use size)\n'
' ╎ constraints: BoxConstraints(w=800.0, h=600.0)\n'
' ╎ size: Size(800.0, 600.0)\n'
' ╎ additionalConstraints: BoxConstraints(biggest)\n'
' ╎\n'
' ╎╌offstage 1: RenderLimitedBox#b6f09 NEEDS-LAYOUT NEEDS-PAINT\n'
' ╎ │ parentData: not positioned; offset=Offset(0.0, 0.0)\n'
' ╎ │ constraints: MISSING\n'
' ╎ │ size: MISSING\n'
' ╎ │ maxWidth: 0.0\n'
' ╎ │ maxHeight: 0.0\n'
' ╎ │\n'
' ╎ └─child: RenderConstrainedBox#5a057 NEEDS-LAYOUT NEEDS-PAINT\n'
' ╎ parentData: <none>\n'
' ╎ constraints: MISSING\n'
' ╎ size: MISSING\n'
' ╎ additionalConstraints: BoxConstraints(biggest)\n'
' ╎\n'
' └╌offstage 2: RenderLimitedBox#f689e NEEDS-LAYOUT NEEDS-PAINT\n'
' │ parentData: not positioned; offset=Offset(0.0, 0.0)\n'
' │ constraints: MISSING\n'
' │ size: MISSING\n'
' │ maxWidth: 0.0\n'
' │ maxHeight: 0.0\n'
' │\n'
' └─child: RenderConstrainedBox#c15f0 NEEDS-LAYOUT NEEDS-PAINT\n'
' parentData: <none>\n'
' constraints: MISSING\n'
' size: MISSING\n'
' additionalConstraints: BoxConstraints(biggest)\n'
),
);
});
}