keep_alive_test.dart 35.2 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io' show Platform;

7
import 'package:flutter/foundation.dart';
8
import 'package:flutter/widgets.dart';
9
import 'package:flutter_test/flutter_test.dart';
10 11

class Leaf extends StatefulWidget {
12
  const Leaf({
13
    super.key,
14
    required this.child,
15
  });
16 17
  final Widget child;
  @override
18
  State<Leaf> createState() => _LeafState();
19 20 21 22 23 24 25 26 27 28 29
}

class _LeafState extends State<Leaf> {
  bool _keepAlive = false;

  void setKeepAlive(bool value) {
    setState(() { _keepAlive = value; });
  }

  @override
  Widget build(BuildContext context) {
30
    return KeepAlive(
31 32 33 34 35 36 37
      keepAlive: _keepAlive,
      child: widget.child,
    );
  }
}

List<Widget> generateList(Widget child) {
38
  return List<Widget>.generate(
39
    100,
40 41
    (int index) => Leaf(
      key: GlobalObjectKey<_LeafState>(index),
42 43 44 45 46 47 48 49
      child: child,
    ),
    growable: false,
  );
}

void main() {
  testWidgets('KeepAlive with ListView with itemExtent', (WidgetTester tester) async {
50
    await tester.pumpWidget(
51
      Directionality(
52
        textDirection: TextDirection.ltr,
53
        child: ListView(
54
          cacheExtent: 0.0,
55 56
          addAutomaticKeepAlives: false,
          addRepaintBoundaries: false,
57
          addSemanticIndexes: false,
58 59 60 61 62
          itemExtent: 12.3, // about 50 widgets visible
          children: generateList(const Placeholder()),
        ),
      ),
    );
63 64
    expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
65 66 67 68
    expect(find.byKey(const GlobalObjectKey<_LeafState>(59), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(60), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(61), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
69 70
    await tester.drag(find.byType(ListView), const Offset(0.0, -300.0)); // about 25 widgets' worth
    await tester.pump();
71
    expect(find.byKey(const GlobalObjectKey<_LeafState>(3), skipOffstage: false), findsNothing);
72 73 74 75
    expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(59)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(61)), findsOneWidget);
76
    expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
77
    const GlobalObjectKey<_LeafState>(60).currentState!.setKeepAlive(true);
78 79 80 81
    await tester.drag(find.byType(ListView), const Offset(0.0, 300.0)); // back to top
    await tester.pump();
    expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
82 83 84 85 86
    expect(find.byKey(const GlobalObjectKey<_LeafState>(59), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(60), skipOffstage: false), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(61), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
87
    const GlobalObjectKey<_LeafState>(60).currentState!.setKeepAlive(false);
88 89 90
    await tester.pump();
    expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
91 92 93 94
    expect(find.byKey(const GlobalObjectKey<_LeafState>(59), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(60), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(61), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
95 96 97
  });

  testWidgets('KeepAlive with ListView without itemExtent', (WidgetTester tester) async {
98
    await tester.pumpWidget(
99
      Directionality(
100
        textDirection: TextDirection.ltr,
101
        child: ListView(
102
          cacheExtent: 0.0,
103 104
          addAutomaticKeepAlives: false,
          addRepaintBoundaries: false,
105
          addSemanticIndexes: false,
106
          children: generateList(const SizedBox(height: 12.3, child: Placeholder())), // about 50 widgets visible
107 108 109
        ),
      ),
    );
110 111
    expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
112 113 114 115
    expect(find.byKey(const GlobalObjectKey<_LeafState>(59), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(60), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(61), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
116 117
    await tester.drag(find.byType(ListView), const Offset(0.0, -300.0)); // about 25 widgets' worth
    await tester.pump();
118
    expect(find.byKey(const GlobalObjectKey<_LeafState>(3), skipOffstage: false), findsNothing);
119 120 121 122
    expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(59)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(61)), findsOneWidget);
123
    expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
124
    const GlobalObjectKey<_LeafState>(60).currentState!.setKeepAlive(true);
125 126 127 128
    await tester.drag(find.byType(ListView), const Offset(0.0, 300.0)); // back to top
    await tester.pump();
    expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
129 130 131 132 133
    expect(find.byKey(const GlobalObjectKey<_LeafState>(59), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(60), skipOffstage: false), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(61), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
134
    const GlobalObjectKey<_LeafState>(60).currentState!.setKeepAlive(false);
135 136 137
    await tester.pump();
    expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
138 139 140 141
    expect(find.byKey(const GlobalObjectKey<_LeafState>(59), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(60), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(61), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
142 143 144
  });

  testWidgets('KeepAlive with GridView', (WidgetTester tester) async {
145
    await tester.pumpWidget(
146
      Directionality(
147
        textDirection: TextDirection.ltr,
148
        child: GridView.count(
149
          cacheExtent: 0.0,
150 151
          addAutomaticKeepAlives: false,
          addRepaintBoundaries: false,
152
          addSemanticIndexes: false,
153 154
          crossAxisCount: 2,
          childAspectRatio: 400.0 / 24.6, // about 50 widgets visible
155
          children: generateList(const Placeholder()),
156 157 158
        ),
      ),
    );
159 160
    expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
161 162 163 164
    expect(find.byKey(const GlobalObjectKey<_LeafState>(59), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(60), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(61), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
165 166
    await tester.drag(find.byType(GridView), const Offset(0.0, -300.0)); // about 25 widgets' worth
    await tester.pump();
167
    expect(find.byKey(const GlobalObjectKey<_LeafState>(3), skipOffstage: false), findsNothing);
168 169 170 171
    expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(59)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(61)), findsOneWidget);
172
    expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
173
    const GlobalObjectKey<_LeafState>(60).currentState!.setKeepAlive(true);
174 175 176 177
    await tester.drag(find.byType(GridView), const Offset(0.0, 300.0)); // back to top
    await tester.pump();
    expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
178 179 180 181 182
    expect(find.byKey(const GlobalObjectKey<_LeafState>(59), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(60), skipOffstage: false), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(60)), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(61), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
183
    const GlobalObjectKey<_LeafState>(60).currentState!.setKeepAlive(false);
184 185 186
    await tester.pump();
    expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(30)), findsOneWidget);
187 188 189 190
    expect(find.byKey(const GlobalObjectKey<_LeafState>(59), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(60), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(61), skipOffstage: false), findsNothing);
    expect(find.byKey(const GlobalObjectKey<_LeafState>(90), skipOffstage: false), findsNothing);
191 192 193
  });

  testWidgets('KeepAlive render tree description', (WidgetTester tester) async {
194
    await tester.pumpWidget(
195
      Directionality(
196
        textDirection: TextDirection.ltr,
197
        child: ListView(
198 199
          addAutomaticKeepAlives: false,
          addRepaintBoundaries: false,
200
          addSemanticIndexes: false,
201 202 203 204 205
          itemExtent: 400.0, // 2 visible children
          children: generateList(const Placeholder()),
        ),
      ),
    );
206
    // The important lines below are the ones marked with "<----"
207
    expect(tester.binding.renderView.toStringDeep(minLevel: DiagnosticLevel.info), equalsIgnoringHashCodes(
208
      '_ReusableRenderView#00000\n'
209
      ' │ debug mode enabled - ${Platform.operatingSystem}\n'
210
      ' │ view size: Size(2400.0, 1800.0) (in physical pixels)\n'
211 212 213 214
      ' │ device pixel ratio: 3.0 (physical pixels per logical pixel)\n'
      ' │ configuration: Size(800.0, 600.0) at 3.0x (in logical pixels)\n'
      ' │\n'
      ' └─child: RenderRepaintBoundary#00000\n'
215
      '   │ needs compositing\n'
216 217 218 219 220 221 222 223 224
      '   │ parentData: <none>\n'
      '   │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '   │ layer: OffsetLayer#00000\n'
      '   │ size: Size(800.0, 600.0)\n'
      '   │ metrics: 0.0% useful (1 bad vs 0 good)\n'
      '   │ diagnosis: insufficient data to draw conclusion (less than five\n'
      '   │   repaints)\n'
      '   │\n'
      '   └─child: RenderCustomPaint#00000\n'
225
      '     │ needs compositing\n'
226 227 228
      '     │ parentData: <none> (can use size)\n'
      '     │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '     │ size: Size(800.0, 600.0)\n'
Ian Hickson's avatar
Ian Hickson committed
229 230 231 232 233
      '     │ painter: null\n'
      '     │ foregroundPainter:\n'
      '     │   _GlowingOverscrollIndicatorPainter(_GlowController(color:\n'
      '     │   Color(0xffffffff), axis: vertical), _GlowController(color:\n'
      '     │   Color(0xffffffff), axis: vertical))\n'
234 235
      '     │\n'
      '     └─child: RenderRepaintBoundary#00000\n'
236
      '       │ needs compositing\n'
237 238 239 240 241 242 243 244
      '       │ parentData: <none> (can use size)\n'
      '       │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '       │ layer: OffsetLayer#00000\n'
      '       │ size: Size(800.0, 600.0)\n'
      '       │ metrics: 0.0% useful (1 bad vs 0 good)\n'
      '       │ diagnosis: insufficient data to draw conclusion (less than five\n'
      '       │   repaints)\n'
      '       │\n'
Ian Hickson's avatar
Ian Hickson committed
245
      '       └─child: _RenderScrollSemantics#00000\n'
246
      '         │ needs compositing\n'
247 248
      '         │ parentData: <none> (can use size)\n'
      '         │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
249
      '         │ semantics node: SemanticsNode#1\n'
250
      '         │ semantic boundary\n'
251 252
      '         │ size: Size(800.0, 600.0)\n'
      '         │\n'
253
      '         └─child: RenderPointerListener#00000\n'
254
      '           │ needs compositing\n'
255 256 257
      '           │ parentData: <none> (can use size)\n'
      '           │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '           │ size: Size(800.0, 600.0)\n'
258 259
      '           │ behavior: deferToChild\n'
      '           │ listeners: signal\n'
260
      '           │\n'
261
      '           └─child: RenderSemanticsGestureHandler#00000\n'
262
      '             │ needs compositing\n'
263 264 265
      '             │ parentData: <none> (can use size)\n'
      '             │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '             │ size: Size(800.0, 600.0)\n'
266
      '             │ behavior: opaque\n'
267
      '             │ gestures: vertical scroll\n'
268
      '             │\n'
269
      '             └─child: RenderPointerListener#00000\n'
270
      '               │ needs compositing\n'
271 272 273
      '               │ parentData: <none> (can use size)\n'
      '               │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '               │ size: Size(800.0, 600.0)\n'
274
      '               │ behavior: opaque\n'
275
      '               │ listeners: down, panZoomStart\n'
276
      '               │\n'
277
      '               └─child: RenderSemanticsAnnotations#00000\n'
278
      '                 │ needs compositing\n'
279 280 281
      '                 │ parentData: <none> (can use size)\n'
      '                 │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '                 │ size: Size(800.0, 600.0)\n'
282
      '                 │\n'
283
      '                 └─child: RenderIgnorePointer#00000\n'
284
      '                   │ needs compositing\n'
285 286 287
      '                   │ parentData: <none> (can use size)\n'
      '                   │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '                   │ size: Size(800.0, 600.0)\n'
288
      '                   │ ignoring: false\n'
289
      '                   │ ignoringSemantics: null\n'
290
      '                   │\n'
291
      '                   └─child: RenderViewport#00000\n'
292
      '                     │ needs compositing\n'
293 294 295 296 297 298 299 300
      '                     │ parentData: <none> (can use size)\n'
      '                     │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '                     │ layer: OffsetLayer#00000\n'
      '                     │ size: Size(800.0, 600.0)\n'
      '                     │ axisDirection: down\n'
      '                     │ crossAxisDirection: right\n'
      '                     │ offset: ScrollPositionWithSingleContext#00000(offset: 0.0, range:\n'
      '                     │   0.0..39400.0, viewport: 600.0, ScrollableState,\n'
301 302 303
      '                     │   AlwaysScrollableScrollPhysics -> ClampingScrollPhysics ->\n'
      '                     │   RangeMaintainingScrollPhysics, IdleScrollActivity#00000,\n'
      '                     │   ScrollDirection.idle)\n'
304
      '                     │ anchor: 0.0\n'
305
      '                     │\n'
306
      '                     └─center child: RenderSliverPadding#00000 relayoutBoundary=up1\n'
307 308 309 310 311
      '                       │ parentData: paintOffset=Offset(0.0, 0.0) (can use size)\n'
      '                       │ constraints: SliverConstraints(AxisDirection.down,\n'
      '                       │   GrowthDirection.forward, ScrollDirection.idle, scrollOffset:\n'
      '                       │   0.0, remainingPaintExtent: 600.0, crossAxisExtent: 800.0,\n'
      '                       │   crossAxisDirection: AxisDirection.right,\n'
312 313
      '                       │   viewportMainAxisExtent: 600.0, remainingCacheExtent: 850.0,\n'
      '                       │   cacheOrigin: 0.0)\n'
314 315 316
      '                       │ geometry: SliverGeometry(scrollExtent: 40000.0, paintExtent:\n'
      '                       │   600.0, maxPaintExtent: 40000.0, hasVisualOverflow: true,\n'
      '                       │   cacheExtent: 850.0)\n'
317 318
      '                       │ padding: EdgeInsets.zero\n'
      '                       │ textDirection: ltr\n'
319
      '                       │\n'
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
      '                       └─child: RenderSliverFixedExtentList#00000 relayoutBoundary=up2\n'
      '                         │ parentData: paintOffset=Offset(0.0, 0.0) (can use size)\n'
      '                         │ constraints: SliverConstraints(AxisDirection.down,\n'
      '                         │   GrowthDirection.forward, ScrollDirection.idle, scrollOffset:\n'
      '                         │   0.0, remainingPaintExtent: 600.0, crossAxisExtent: 800.0,\n'
      '                         │   crossAxisDirection: AxisDirection.right,\n'
      '                         │   viewportMainAxisExtent: 600.0, remainingCacheExtent: 850.0,\n'
      '                         │   cacheOrigin: 0.0)\n'
      '                         │ geometry: SliverGeometry(scrollExtent: 40000.0, paintExtent:\n'
      '                         │   600.0, maxPaintExtent: 40000.0, hasVisualOverflow: true,\n'
      '                         │   cacheExtent: 850.0)\n'
      '                         │ currently live children: 0 to 2\n'
      '                         │\n'
      '                         ├─child with index 0: RenderLimitedBox#00000\n'
      '                         │ │ parentData: index=0; layoutOffset=0.0\n'
      '                         │ │ constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                         │ │ size: Size(800.0, 400.0)\n'
      '                         │ │ maxWidth: 400.0\n'
      '                         │ │ maxHeight: 400.0\n'
      '                         │ │\n'
      '                         │ └─child: RenderCustomPaint#00000\n'
      '                         │     parentData: <none> (can use size)\n'
      '                         │     constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                         │     size: Size(800.0, 400.0)\n'
      '                         │     painter: _PlaceholderPainter#00000()\n'
      '                         │     preferredSize: Size(Infinity, Infinity)\n'
346
      '                         │\n'
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
      '                         ├─child with index 1: RenderLimitedBox#00000\n'                                      // <----- no dashed line starts here
      '                         │ │ parentData: index=1; layoutOffset=400.0\n'
      '                         │ │ constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                         │ │ size: Size(800.0, 400.0)\n'
      '                         │ │ maxWidth: 400.0\n'
      '                         │ │ maxHeight: 400.0\n'
      '                         │ │\n'
      '                         │ └─child: RenderCustomPaint#00000\n'
      '                         │     parentData: <none> (can use size)\n'
      '                         │     constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                         │     size: Size(800.0, 400.0)\n'
      '                         │     painter: _PlaceholderPainter#00000()\n'
      '                         │     preferredSize: Size(Infinity, Infinity)\n'
      '                         │\n'
      '                         └─child with index 2: RenderLimitedBox#00000 NEEDS-PAINT\n'
      '                           │ parentData: index=2; layoutOffset=800.0\n'
      '                           │ constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                           │ size: Size(800.0, 400.0)\n'
      '                           │ maxWidth: 400.0\n'
      '                           │ maxHeight: 400.0\n'
      '                           │\n'
      '                           └─child: RenderCustomPaint#00000 NEEDS-PAINT\n'
      '                               parentData: <none> (can use size)\n'
      '                               constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                               size: Size(800.0, 400.0)\n'
      '                               painter: _PlaceholderPainter#00000()\n'
      '                               preferredSize: Size(Infinity, Infinity)\n',
374
    ));
375
    const GlobalObjectKey<_LeafState>(0).currentState!.setKeepAlive(true);
376 377
    await tester.drag(find.byType(ListView), const Offset(0.0, -1000.0));
    await tester.pump();
378
    const GlobalObjectKey<_LeafState>(3).currentState!.setKeepAlive(true);
379 380
    await tester.drag(find.byType(ListView), const Offset(0.0, -1000.0));
    await tester.pump();
381
    expect(tester.binding.renderView.toStringDeep(minLevel: DiagnosticLevel.info), equalsIgnoringHashCodes(
382
      '_ReusableRenderView#00000\n'
383
      ' │ debug mode enabled - ${Platform.operatingSystem}\n'
384
      ' │ view size: Size(2400.0, 1800.0) (in physical pixels)\n'
385 386 387 388
      ' │ device pixel ratio: 3.0 (physical pixels per logical pixel)\n'
      ' │ configuration: Size(800.0, 600.0) at 3.0x (in logical pixels)\n'
      ' │\n'
      ' └─child: RenderRepaintBoundary#00000\n'
389
      '   │ needs compositing\n'
390 391 392 393 394 395 396 397 398
      '   │ parentData: <none>\n'
      '   │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '   │ layer: OffsetLayer#00000\n'
      '   │ size: Size(800.0, 600.0)\n'
      '   │ metrics: 0.0% useful (1 bad vs 0 good)\n'
      '   │ diagnosis: insufficient data to draw conclusion (less than five\n'
      '   │   repaints)\n'
      '   │\n'
      '   └─child: RenderCustomPaint#00000\n'
399
      '     │ needs compositing\n'
400 401 402
      '     │ parentData: <none> (can use size)\n'
      '     │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '     │ size: Size(800.0, 600.0)\n'
Ian Hickson's avatar
Ian Hickson committed
403 404 405 406 407
      '     │ painter: null\n'
      '     │ foregroundPainter:\n'
      '     │   _GlowingOverscrollIndicatorPainter(_GlowController(color:\n'
      '     │   Color(0xffffffff), axis: vertical), _GlowController(color:\n'
      '     │   Color(0xffffffff), axis: vertical))\n'
408 409
      '     │\n'
      '     └─child: RenderRepaintBoundary#00000\n'
410
      '       │ needs compositing\n'
411 412 413 414 415 416 417 418
      '       │ parentData: <none> (can use size)\n'
      '       │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '       │ layer: OffsetLayer#00000\n'
      '       │ size: Size(800.0, 600.0)\n'
      '       │ metrics: 0.0% useful (1 bad vs 0 good)\n'
      '       │ diagnosis: insufficient data to draw conclusion (less than five\n'
      '       │   repaints)\n'
      '       │\n'
Ian Hickson's avatar
Ian Hickson committed
419
      '       └─child: _RenderScrollSemantics#00000\n'
420
      '         │ needs compositing\n'
421 422
      '         │ parentData: <none> (can use size)\n'
      '         │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
423
      '         │ semantics node: SemanticsNode#1\n'
424
      '         │ semantic boundary\n'
425 426
      '         │ size: Size(800.0, 600.0)\n'
      '         │\n'
427
      '         └─child: RenderPointerListener#00000\n'
428
      '           │ needs compositing\n'
429 430 431
      '           │ parentData: <none> (can use size)\n'
      '           │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '           │ size: Size(800.0, 600.0)\n'
432 433
      '           │ behavior: deferToChild\n'
      '           │ listeners: signal\n'
434
      '           │\n'
435
      '           └─child: RenderSemanticsGestureHandler#00000\n'
436
      '             │ needs compositing\n'
437 438 439
      '             │ parentData: <none> (can use size)\n'
      '             │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '             │ size: Size(800.0, 600.0)\n'
440
      '             │ behavior: opaque\n'
441
      '             │ gestures: vertical scroll\n'
442
      '             │\n'
443
      '             └─child: RenderPointerListener#00000\n'
444
      '               │ needs compositing\n'
445 446 447
      '               │ parentData: <none> (can use size)\n'
      '               │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '               │ size: Size(800.0, 600.0)\n'
448
      '               │ behavior: opaque\n'
449
      '               │ listeners: down, panZoomStart\n'
450
      '               │\n'
451
      '               └─child: RenderSemanticsAnnotations#00000\n'
452
      '                 │ needs compositing\n'
453 454 455
      '                 │ parentData: <none> (can use size)\n'
      '                 │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '                 │ size: Size(800.0, 600.0)\n'
456
      '                 │\n'
457
      '                 └─child: RenderIgnorePointer#00000\n'
458
      '                   │ needs compositing\n'
459 460 461
      '                   │ parentData: <none> (can use size)\n'
      '                   │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '                   │ size: Size(800.0, 600.0)\n'
462
      '                   │ ignoring: false\n'
463
      '                   │ ignoringSemantics: null\n'
464
      '                   │\n'
465
      '                   └─child: RenderViewport#00000\n'
466
      '                     │ needs compositing\n'
467 468 469 470 471 472 473 474
      '                     │ parentData: <none> (can use size)\n'
      '                     │ constraints: BoxConstraints(w=800.0, h=600.0)\n'
      '                     │ layer: OffsetLayer#00000\n'
      '                     │ size: Size(800.0, 600.0)\n'
      '                     │ axisDirection: down\n'
      '                     │ crossAxisDirection: right\n'
      '                     │ offset: ScrollPositionWithSingleContext#00000(offset: 2000.0,\n'
      '                     │   range: 0.0..39400.0, viewport: 600.0, ScrollableState,\n'
475 476 477
      '                     │   AlwaysScrollableScrollPhysics -> ClampingScrollPhysics ->\n'
      '                     │   RangeMaintainingScrollPhysics, IdleScrollActivity#00000,\n'
      '                     │   ScrollDirection.idle)\n'
478
      '                     │ anchor: 0.0\n'
479
      '                     │\n'
480
      '                     └─center child: RenderSliverPadding#00000 relayoutBoundary=up1\n'
481 482 483 484 485
      '                       │ parentData: paintOffset=Offset(0.0, 0.0) (can use size)\n'
      '                       │ constraints: SliverConstraints(AxisDirection.down,\n'
      '                       │   GrowthDirection.forward, ScrollDirection.idle, scrollOffset:\n'
      '                       │   2000.0, remainingPaintExtent: 600.0, crossAxisExtent: 800.0,\n'
      '                       │   crossAxisDirection: AxisDirection.right,\n'
486 487
      '                       │   viewportMainAxisExtent: 600.0, remainingCacheExtent: 1100.0,\n'
      '                       │   cacheOrigin: -250.0)\n'
488 489 490
      '                       │ geometry: SliverGeometry(scrollExtent: 40000.0, paintExtent:\n'
      '                       │   600.0, maxPaintExtent: 40000.0, hasVisualOverflow: true,\n'
      '                       │   cacheExtent: 1100.0)\n'
491 492
      '                       │ padding: EdgeInsets.zero\n'
      '                       │ textDirection: ltr\n'
493
      '                       │\n'
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
      '                       └─child: RenderSliverFixedExtentList#00000 relayoutBoundary=up2\n'
      '                         │ parentData: paintOffset=Offset(0.0, 0.0) (can use size)\n'
      '                         │ constraints: SliverConstraints(AxisDirection.down,\n'
      '                         │   GrowthDirection.forward, ScrollDirection.idle, scrollOffset:\n'
      '                         │   2000.0, remainingPaintExtent: 600.0, crossAxisExtent: 800.0,\n'
      '                         │   crossAxisDirection: AxisDirection.right,\n'
      '                         │   viewportMainAxisExtent: 600.0, remainingCacheExtent: 1100.0,\n'
      '                         │   cacheOrigin: -250.0)\n'
      '                         │ geometry: SliverGeometry(scrollExtent: 40000.0, paintExtent:\n'
      '                         │   600.0, maxPaintExtent: 40000.0, hasVisualOverflow: true,\n'
      '                         │   cacheExtent: 1100.0)\n'
      '                         │ currently live children: 4 to 7\n'
      '                         │\n'
      '                         ├─child with index 4: RenderLimitedBox#00000 NEEDS-PAINT\n'
      '                         │ │ parentData: index=4; layoutOffset=1600.0\n'
      '                         │ │ constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                         │ │ size: Size(800.0, 400.0)\n'
      '                         │ │ maxWidth: 400.0\n'
      '                         │ │ maxHeight: 400.0\n'
      '                         │ │\n'
      '                         │ └─child: RenderCustomPaint#00000 NEEDS-PAINT\n'
      '                         │     parentData: <none> (can use size)\n'
      '                         │     constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                         │     size: Size(800.0, 400.0)\n'
      '                         │     painter: _PlaceholderPainter#00000()\n'
      '                         │     preferredSize: Size(Infinity, Infinity)\n'
      '                         │\n'
      '                         ├─child with index 5: RenderLimitedBox#00000\n'                                     // <----- this is index 5, not 0
      '                         │ │ parentData: index=5; layoutOffset=2000.0\n'
      '                         │ │ constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                         │ │ size: Size(800.0, 400.0)\n'
      '                         │ │ maxWidth: 400.0\n'
      '                         │ │ maxHeight: 400.0\n'
      '                         │ │\n'
      '                         │ └─child: RenderCustomPaint#00000\n'
      '                         │     parentData: <none> (can use size)\n'
      '                         │     constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                         │     size: Size(800.0, 400.0)\n'
      '                         │     painter: _PlaceholderPainter#00000()\n'
      '                         │     preferredSize: Size(Infinity, Infinity)\n'
534
      '                         │\n'
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
      '                         ├─child with index 6: RenderLimitedBox#00000\n'
      '                         │ │ parentData: index=6; layoutOffset=2400.0\n'
      '                         │ │ constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                         │ │ size: Size(800.0, 400.0)\n'
      '                         │ │ maxWidth: 400.0\n'
      '                         │ │ maxHeight: 400.0\n'
      '                         │ │\n'
      '                         │ └─child: RenderCustomPaint#00000\n'
      '                         │     parentData: <none> (can use size)\n'
      '                         │     constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                         │     size: Size(800.0, 400.0)\n'
      '                         │     painter: _PlaceholderPainter#00000()\n'
      '                         │     preferredSize: Size(Infinity, Infinity)\n'
      '                         │\n'
      '                         ├─child with index 7: RenderLimitedBox#00000 NEEDS-PAINT\n'
      '                         ╎ │ parentData: index=7; layoutOffset=2800.0\n'
      '                         ╎ │ constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                         ╎ │ size: Size(800.0, 400.0)\n'
      '                         ╎ │ maxWidth: 400.0\n'
      '                         ╎ │ maxHeight: 400.0\n'
      '                         ╎ │\n'
      '                         ╎ └─child: RenderCustomPaint#00000 NEEDS-PAINT\n'
      '                         ╎     parentData: <none> (can use size)\n'
      '                         ╎     constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                         ╎     size: Size(800.0, 400.0)\n'
      '                         ╎     painter: _PlaceholderPainter#00000()\n'
      '                         ╎     preferredSize: Size(Infinity, Infinity)\n'
      '                         ╎\n'
      '                         ╎╌child with index 0 (kept alive but not laid out): RenderLimitedBox#00000\n'               // <----- this one is index 0 and is marked as being kept alive but not laid out
      '                         ╎ │ parentData: index=0; keepAlive; layoutOffset=0.0\n'
      '                         ╎ │ constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                         ╎ │ size: Size(800.0, 400.0)\n'
      '                         ╎ │ maxWidth: 400.0\n'
      '                         ╎ │ maxHeight: 400.0\n'
      '                         ╎ │\n'
      '                         ╎ └─child: RenderCustomPaint#00000\n'
      '                         ╎     parentData: <none> (can use size)\n'
      '                         ╎     constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                         ╎     size: Size(800.0, 400.0)\n'
      '                         ╎     painter: _PlaceholderPainter#00000()\n'
      '                         ╎     preferredSize: Size(Infinity, Infinity)\n'
      '                         ╎\n'
      '                         └╌child with index 3 (kept alive but not laid out): RenderLimitedBox#00000\n'
      '                           │ parentData: index=3; keepAlive; layoutOffset=1200.0\n'
      '                           │ constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                           │ size: Size(800.0, 400.0)\n'
      '                           │ maxWidth: 400.0\n'
      '                           │ maxHeight: 400.0\n'
      '                           │\n'
      '                           └─child: RenderCustomPaint#00000\n'
      '                               parentData: <none> (can use size)\n'
      '                               constraints: BoxConstraints(w=800.0, h=400.0)\n'
      '                               size: Size(800.0, 400.0)\n'
      '                               painter: _PlaceholderPainter#00000()\n'
      '                               preferredSize: Size(Infinity, Infinity)\n',
590
    ));
591
  }, skip: kIsWeb); // https://github.com/flutter/flutter/issues/87876
592
}