• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Duit-Foundation / flutter_duit / 21026233449

15 Jan 2026 09:26AM UTC coverage: 80.184% (-8.3%) from 88.441%
21026233449

push

github

web-flow
feat: Capability-based API migration pt2 (#323)

162 of 408 new or added lines in 23 files covered. (39.71%)

328 existing lines in 17 files now uncovered.

4354 of 5430 relevant lines covered (80.18%)

34.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.63
/lib/src/ui/widget_from_element.dart
1
part of "element_property_view.dart";
2

3
@preferInline
16✔
4
List<Widget?> _mapToNullableWidgetList(ElementPropertyView model) =>
5
    model.children
16✔
6
        .map<Widget?>(
16✔
7
          (child) => child == null ? null : _buildWidget(child),
32✔
8
        )
9
        .toList();
16✔
10

11
Widget _buildText(ElementPropertyView model) {
156✔
12
  return switch (model.controlled) {
156✔
13
    true => DuitControlledText(controller: model.viewController),
228✔
14
    false => DuitText(attributes: model.attributes),
408✔
15
  };
16
}
17

18
Widget _buildRow(ElementPropertyView model) {
20✔
19
  return switch (model.controlled) {
20✔
20
    true => DuitControlledRow(
24✔
21
        controller: model.viewController,
4✔
22
        children: model.children.map(_buildWidget).toList(),
12✔
23
      ),
24
    false => DuitRow(
32✔
25
        attributes: model.attributes,
16✔
26
        children: model.children.map(_buildWidget).toList(),
48✔
27
      ),
28
  };
29
}
30

31
Widget _buildStack(ElementPropertyView model) {
20✔
32
  return switch (model.controlled) {
20✔
33
    true => DuitControlledStack(
24✔
34
        controller: model.viewController,
4✔
35
        children: model.children.map(_buildWidget).toList(),
12✔
36
      ),
37
    false => DuitStack(
40✔
38
        attributes: model.attributes,
20✔
39
        children: model.children.map(_buildWidget).toList(),
60✔
40
      ),
41
  };
42
}
43

44
Widget _buildElevatedButton(ElementPropertyView model) {
12✔
45
  return DuitElevatedButton(
12✔
46
    controller: model.viewController,
12✔
47
    child: _buildWidget(model.child),
24✔
48
  );
49
}
50

51
Widget _buildTextField(ElementPropertyView model) => DuitTextField(
24✔
52
      controller: model.viewController,
12✔
53
    );
54

55
Widget _buildSlider(ElementPropertyView model) => DuitSlider(
8✔
56
      controller: model.viewController,
4✔
57
    );
58

59
Widget _buildSwitch(ElementPropertyView model) => DuitSwitch(
8✔
60
      controller: model.viewController,
4✔
61
    );
62

63
Widget _buildRichText(ElementPropertyView model) {
4✔
64
  return switch (model.controlled) {
4✔
65
    true => DuitControlledRichText(
8✔
66
        controller: model.viewController,
4✔
67
      ),
68
    false => DuitRichText(
8✔
69
        attributes: model.attributes,
4✔
70
      ),
71
  };
72
}
73

74
Widget _buildCheckbox(ElementPropertyView model) => DuitCheckbox(
8✔
75
      controller: model.viewController,
4✔
76
    );
77

78
Widget _buildRadio(ElementPropertyView model) {
4✔
79
  return switch (model.controlled) {
4✔
80
    true => DuitControlledRadio(
8✔
81
        controller: model.viewController,
4✔
82
      ),
83
    false => DuitRadio(
8✔
84
        attributes: model.attributes,
4✔
85
      ),
86
  };
87
}
88

89
Widget _buildRadioGroupContext(ElementPropertyView model) {
4✔
90
  return DuitRadioGroupContextProvider(
4✔
91
    controller: model.viewController,
4✔
92
    child: _buildWidget(model.child),
8✔
93
  );
94
}
95

96
Widget _buildColumn(ElementPropertyView model) {
28✔
97
  return switch (model.controlled) {
28✔
98
    true => DuitControlledColumn(
32✔
99
        controller: model.viewController,
4✔
100
        children: model.children.map(_buildWidget).toList(),
12✔
101
      ),
102
    false => DuitColumn(
48✔
103
        attributes: model.attributes,
24✔
104
        children: model.children.map(_buildWidget).toList(),
72✔
105
      ),
106
  };
107
}
108

109
Widget _buildAbsorbPointer(ElementPropertyView model) {
4✔
110
  return switch (model.controlled) {
4✔
111
    true => DuitControlledAbsorbPointer(
8✔
112
        controller: model.viewController,
4✔
113
        child: _buildWidget(model.child),
8✔
114
      ),
115
    false => DuitAbsorbPointer(
8✔
116
        attributes: model.attributes,
4✔
117
        child: _buildWidget(model.child),
8✔
118
      ),
119
  };
120
}
121

122
Widget _buildOffstage(ElementPropertyView model) {
4✔
123
  return switch (model.controlled) {
4✔
124
    true => DuitControlledOffstage(
8✔
125
        controller: model.viewController,
4✔
126
        child: _buildWidget(model.child),
8✔
127
      ),
128
    false => DuitOffstage(
8✔
129
        attributes: model.attributes,
4✔
130
        child: _buildWidget(model.child),
8✔
131
      ),
132
  };
133
}
134

135
Widget _buildDecoratedBox(ElementPropertyView model) {
4✔
136
  return switch (model.controlled) {
4✔
137
    true => DuitControlledDecoratedBox(
8✔
138
        controller: model.viewController,
4✔
139
        child: _buildWidget(model.child),
8✔
140
      ),
141
    false => DuitDecoratedBox(
8✔
142
        attributes: model.attributes,
4✔
143
        child: _buildWidget(model.child),
8✔
144
      ),
145
  };
146
}
147

148
Widget _buildCenter(ElementPropertyView model) {
8✔
149
  return switch (model.controlled) {
8✔
150
    true => DuitControlledCenter(
12✔
151
        controller: model.viewController,
4✔
152
        child: _buildWidget(model.child),
8✔
153
      ),
154
    false => DuitCenter(
16✔
155
        attributes: model.attributes,
8✔
156
        child: _buildWidget(model.child),
16✔
157
      ),
158
  };
159
}
160

161
Widget _buildAlign(ElementPropertyView model) {
8✔
162
  return switch (model.controlled) {
8✔
163
    true => DuitControlledAlign(
12✔
164
        controller: model.viewController,
4✔
165
        child: _buildWidget(model.child),
8✔
166
      ),
167
    false => DuitAlign(
16✔
168
        attributes: model.attributes,
8✔
169
        child: _buildWidget(model.child),
16✔
170
      ),
171
  };
172
}
173

174
Widget _buildTransform(ElementPropertyView model) {
4✔
175
  return switch (model.controlled) {
4✔
176
    true => DuitControlledTransform(
8✔
177
        controller: model.viewController,
4✔
178
        child: _buildWidget(model.child),
8✔
179
      ),
180
    false => DuitTransform(
8✔
181
        attributes: model.attributes,
4✔
182
        child: _buildWidget(model.child),
8✔
183
      ),
184
  };
185
}
186

187
Widget _buildInkWell(ElementPropertyView model) => DuitInkWell(
8✔
188
      controller: model.viewController,
4✔
189
      child: _buildWidget(model.child),
8✔
190
    );
191

192
Widget _buildAppBar(ElementPropertyView model) {
8✔
193
  final children = _mapToNullableWidgetList(model);
8✔
194

195
  return switch (model.controlled) {
8✔
196
    true => DuitControlledAppBar(
16✔
197
        controller: model.viewController,
8✔
198
        children: children,
199
      ),
200
    false => DuitAppBar(
8✔
201
        attributes: model.attributes,
4✔
202
        children: children,
203
      ),
204
  };
205
}
206

207
Widget _buildScaffold(ElementPropertyView model) {
4✔
208
  final children = _mapToNullableWidgetList(model);
4✔
209

210
  return switch (model.controlled) {
4✔
211
    true => DuitControlledScaffold(
4✔
212
        controller: model.viewController,
×
213
        children: children,
214
      ),
215
    false => DuitScaffold(
8✔
216
        attributes: model.attributes,
4✔
217
        children: children,
218
      ),
219
  };
220
}
221

222
Widget _buildPositioned(ElementPropertyView model) {
4✔
223
  return switch (model.controlled) {
4✔
224
    true => DuitControlledPositioned(
8✔
225
        controller: model.viewController,
4✔
226
        child: _buildWidget(model.child),
8✔
227
      ),
228
    false => DuitPositioned(
8✔
229
        attributes: model.attributes,
4✔
230
        child: _buildWidget(model.child),
8✔
231
      ),
232
  };
233
}
234

235
Widget _buildSubtree(ElementPropertyView model) => DuitSubtree(
8✔
236
      controller: model.viewController,
4✔
237
      child: _buildWidget(model.child),
8✔
238
    );
239

240
Widget _buildMeta(ElementPropertyView model) => DuitMetaWidget(
8✔
241
      controller: model.viewController,
4✔
242
      child: _buildWidget(model.child),
8✔
243
    );
244

245
Widget _buildContainer(ElementPropertyView model) {
156✔
246
  return switch (model.controlled) {
156✔
247
    true => DuitControlledContainer(
168✔
248
        controller: model.viewController,
12✔
249
        child: _buildWidget(model.child),
24✔
250
      ),
251
    false => DuitContainer(
312✔
252
        attributes: model.attributes,
156✔
253
        child: _buildWidget(model.child),
312✔
254
      ),
255
  };
256
}
257

258
Widget _buildSizedBox(ElementPropertyView model) {
12✔
259
  return switch (model.controlled) {
12✔
260
    true => DuitControlledSizedBox(
16✔
261
        controller: model.viewController,
4✔
262
        child: _buildWidget(model.child),
8✔
263
      ),
264
    false => DuitSizedBox(
24✔
265
        attributes: model.attributes,
12✔
266
        child: _buildWidget(model.child),
24✔
267
      ),
268
  };
269
}
270

271
Widget _buildPadding(ElementPropertyView model) {
4✔
272
  return switch (model.controlled) {
4✔
273
    true => DuitControlledPadding(
8✔
274
        controller: model.viewController,
4✔
275
        child: _buildWidget(model.child),
8✔
276
      ),
277
    false => DuitPadding(
8✔
278
        attributes: model.attributes,
4✔
279
        child: _buildWidget(model.child),
8✔
280
      ),
281
  };
282
}
283

284
Widget _buildSingleChildScrollView(ElementPropertyView model) {
4✔
285
  return switch (model.controlled) {
4✔
286
    true => DuitControlledSingleChildScrollView(
8✔
287
        controller: model.viewController,
4✔
288
        child: _buildWidget(model.child),
8✔
289
      ),
290
    false => DuitSingleChildScrollView(
8✔
291
        attributes: model.attributes,
4✔
292
        child: _buildWidget(model.child),
8✔
293
      ),
294
  };
295
}
296

297
Widget _buildAnimatedBuilder(ElementPropertyView model) => DuitAnimatedBuilder(
24✔
298
      controller: model.viewController,
12✔
299
      child: _buildWidget(model.child),
24✔
300
    );
301

302
Widget _buildRepaintBoundary(ElementPropertyView model) {
4✔
303
  return switch (model.controlled) {
4✔
304
    true => DuitControlledRepaintBoundary(
8✔
305
        controller: model.viewController,
4✔
306
        child: _buildWidget(model.child),
8✔
307
      ),
308
    false => DuitRepaintBoundary(
8✔
309
        attributes: model.attributes,
4✔
310
        child: _buildWidget(model.child),
8✔
311
      ),
312
  };
313
}
314

315
Widget _buildOverflowBox(ElementPropertyView model) {
4✔
316
  return switch (model.controlled) {
4✔
317
    true => DuitControlledOverflowBox(
8✔
318
        controller: model.viewController,
4✔
319
        child: _buildWidget(model.child),
8✔
320
      ),
321
    false => DuitOverflowBox(
8✔
322
        attributes: model.attributes,
4✔
323
        child: _buildWidget(model.child),
8✔
324
      ),
325
  };
326
}
327

328
// Image widget
329
Widget _buildImage(ElementPropertyView model) {
×
330
  return switch (model.controlled) {
×
331
    true => DuitControlledImage(
×
332
        controller: model.viewController,
×
333
      ),
334
    false => DuitImage(
×
335
        attributes: model.attributes,
×
336
      ),
337
  };
338
}
339

340
// Animated widgets - all controlled only
341
Widget _buildAnimatedSize(ElementPropertyView model) => DuitAnimatedSize(
8✔
342
      controller: model.viewController,
4✔
343
      child: _buildWidget(model.child),
8✔
344
    );
345

346
Widget _buildAnimatedOpacity(ElementPropertyView model) => DuitAnimatedOpacity(
16✔
347
      controller: model.viewController,
8✔
348
      child: _buildWidget(model.child),
16✔
349
    );
350

351
Widget _buildAnimatedContainer(ElementPropertyView model) =>
4✔
352
    DuitAnimatedContainer(
4✔
353
      controller: model.viewController,
4✔
354
      child: _buildWidget(model.child),
8✔
355
    );
356

357
Widget _buildAnimatedAlign(ElementPropertyView model) => DuitAnimatedAlign(
8✔
358
      controller: model.viewController,
4✔
359
      child: _buildWidget(model.child),
8✔
360
    );
361

362
Widget _buildAnimatedRotation(ElementPropertyView model) =>
4✔
363
    DuitAnimatedRotation(
4✔
364
      controller: model.viewController,
4✔
365
      child: _buildWidget(model.child),
8✔
366
    );
367

368
Widget _buildAnimatedPadding(ElementPropertyView model) => DuitAnimatedPadding(
8✔
369
      controller: model.viewController,
4✔
370
      child: _buildWidget(model.child),
8✔
371
    );
372

373
Widget _buildAnimatedPositioned(ElementPropertyView model) =>
4✔
374
    DuitAnimatedPositioned(
4✔
375
      controller: model.viewController,
4✔
376
      child: _buildWidget(model.child),
8✔
377
    );
378

379
Widget _buildAnimatedScale(ElementPropertyView model) => DuitAnimatedScale(
8✔
380
      controller: model.viewController,
4✔
381
      child: _buildWidget(model.child),
8✔
382
    );
383

384
Widget _buildAnimatedCrossFade(ElementPropertyView model) =>
4✔
385
    DuitAnimatedCrossFade(
4✔
386
      controller: model.viewController,
4✔
387
      children: model.children.map(_buildWidget).toList(),
12✔
388
    );
389

390
Widget _buildAnimatedPhysicalModel(ElementPropertyView model) =>
4✔
391
    DuitAnimatedPhysicalModel(
4✔
392
      controller: model.viewController,
4✔
393
      child: _buildWidget(model.child),
8✔
394
    );
395

396
Widget _buildAnimatedSlide(ElementPropertyView model) => DuitAnimatedSlide(
8✔
397
      controller: model.viewController,
4✔
398
      child: _buildWidget(model.child),
8✔
399
    );
400

401
Widget _buildAnimatedPositionedDirectional(ElementPropertyView model) =>
4✔
402
    DuitAnimatedPositionedDirectionalState(
4✔
403
      controller: model.viewController,
4✔
404
      child: _buildWidget(model.child),
8✔
405
    );
406

407
Widget _buildClipRect(ElementPropertyView model) => switch (model.controlled) {
8✔
408
      true => DuitControlledClipRect(
8✔
409
          controller: model.viewController,
4✔
410
          child: _buildWidget(model.child),
8✔
411
        ),
412
      false => DuitClipRect(
8✔
413
          attributes: model.attributes,
4✔
414
          child: _buildWidget(model.child),
8✔
415
        ),
416
    };
417

418
Widget _buildClipOval(ElementPropertyView model) => switch (model.controlled) {
8✔
419
      true => DuitControlledClipOval(
8✔
420
          controller: model.viewController,
4✔
421
          child: _buildWidget(model.child),
8✔
422
        ),
423
      false => DuitClipOval(
8✔
424
          attributes: model.attributes,
4✔
425
          child: _buildWidget(model.child),
8✔
426
        ),
427
    };
428

429
// Single child widgets with controlled/non-controlled versions
430
Widget _buildIntrinsicHeight(ElementPropertyView model) {
4✔
431
  return switch (model.controlled) {
4✔
432
    true => DuitControlledIntrinsicHeight(
8✔
433
        controller: model.viewController,
4✔
434
        child: _buildWidget(model.child),
8✔
435
      ),
436
    false => DuitIntrinsicHeight(
8✔
437
        attributes: model.attributes,
4✔
438
        child: _buildWidget(model.child),
8✔
439
      ),
440
  };
441
}
442

443
Widget _buildIntrinsicWidth(ElementPropertyView model) {
4✔
444
  return switch (model.controlled) {
4✔
445
    true => DuitControlledIntrinsicWidth(
8✔
446
        controller: model.viewController,
4✔
447
        child: _buildWidget(model.child),
8✔
448
      ),
449
    false => DuitIntrinsicWidth(
8✔
450
        attributes: model.attributes,
4✔
451
        child: _buildWidget(model.child),
8✔
452
      ),
453
  };
454
}
455

456
Widget _buildRotatedBox(ElementPropertyView model) {
4✔
457
  return switch (model.controlled) {
4✔
458
    true => DuitControlledRotatedBox(
8✔
459
        controller: model.viewController,
4✔
460
        child: _buildWidget(model.child),
8✔
461
      ),
462
    false => DuitRotatedBox(
8✔
463
        attributes: model.attributes,
4✔
464
        child: _buildWidget(model.child),
8✔
465
      ),
466
  };
467
}
468

469
Widget _buildConstrainedBox(ElementPropertyView model) {
4✔
470
  return switch (model.controlled) {
4✔
471
    true => DuitControlledConstrainedBox(
8✔
472
        controller: model.viewController,
4✔
473
        child: _buildWidget(model.child),
8✔
474
      ),
475
    false => DuitConstrainedBox(
8✔
476
        attributes: model.attributes,
4✔
477
        child: _buildWidget(model.child),
8✔
478
      ),
479
  };
480
}
481

482
Widget _buildBackdropFilter(ElementPropertyView model) {
4✔
483
  return switch (model.controlled) {
4✔
484
    true => DuitControlledBackdropFilter(
4✔
485
        controller: model.viewController,
×
486
        child: _buildWidget(model.child),
×
487
      ),
488
    false => DuitBackdropFilter(
8✔
489
        attributes: model.attributes,
4✔
490
        child: _buildWidget(model.child),
8✔
491
      ),
492
  };
493
}
494

UNCOV
495
Widget _buildRemoteSubtree(ElementPropertyView model) => DuitRemoteSubtree(
×
UNCOV
496
      controller: model.viewController,
×
497
    );
498

499
Widget _buildSafeArea(ElementPropertyView model) {
4✔
500
  return switch (model.controlled) {
4✔
501
    true => DuitControlledSafeArea(
8✔
502
        controller: model.viewController,
4✔
503
        child: _buildWidget(model.child),
8✔
504
      ),
505
    false => DuitSafeArea(
8✔
506
        attributes: model.attributes,
4✔
507
        child: _buildWidget(model.child),
8✔
508
      ),
509
  };
510
}
511

512
Widget _buildCard(ElementPropertyView model) {
4✔
513
  return switch (model.controlled) {
4✔
514
    true => DuitControlledCard(
8✔
515
        controller: model.viewController,
4✔
516
        child: _buildWidget(model.child),
8✔
517
      ),
518
    false => DuitCard(
8✔
519
        attributes: model.attributes,
4✔
520
        child: _buildWidget(model.child),
8✔
521
      ),
522
  };
523
}
524

525
Widget _buildExpanded(ElementPropertyView model) {
4✔
526
  return switch (model.controlled) {
4✔
527
    true => DuitControlledExpanded(
8✔
528
        controller: model.viewController,
4✔
529
        child: _buildWidget(model.child),
8✔
530
      ),
531
    false => DuitExpanded(
8✔
532
        attributes: model.attributes,
4✔
533
        child: _buildWidget(model.child),
8✔
534
      ),
535
  };
536
}
537

538
Widget _buildGestureDetector(ElementPropertyView model) => DuitGestureDetector(
8✔
539
      controller: model.viewController,
4✔
540
      child: _buildWidget(model.child),
8✔
541
    );
542

543
Widget _buildColoredBox(ElementPropertyView model) {
4✔
544
  return switch (model.controlled) {
4✔
545
    true => DuitControlledColoredBox(
8✔
546
        controller: model.viewController,
4✔
547
        child: _buildWidget(model.child),
8✔
548
      ),
549
    false => DuitColoredBox(
8✔
550
        attributes: model.attributes,
4✔
551
        child: _buildWidget(model.child),
8✔
552
      ),
553
  };
554
}
555

556
Widget _buildLifecycleStateListener(ElementPropertyView model) =>
×
557
    DuitLifecycleStateListener(
×
558
      controller: model.viewController,
×
559
      child: _buildWidget(model.child),
×
560
    );
561

562
Widget _buildIgnorePointer(ElementPropertyView model) {
4✔
563
  return switch (model.controlled) {
4✔
564
    true => DuitControlledIgnorePointer(
8✔
565
        controller: model.viewController,
4✔
566
        child: _buildWidget(model.child),
8✔
567
      ),
568
    false => DuitIgnorePointer(
8✔
569
        attributes: model.attributes,
4✔
570
        child: _buildWidget(model.child),
8✔
571
      ),
572
  };
573
}
574

575
Widget _buildOpacity(ElementPropertyView model) {
4✔
576
  return switch (model.controlled) {
4✔
577
    true => DuitControlledOpacity(
8✔
578
        controller: model.viewController,
4✔
579
        child: _buildWidget(model.child),
8✔
580
      ),
581
    false => DuitOpacity(
8✔
582
        attributes: model.attributes,
4✔
583
        child: _buildWidget(model.child),
8✔
584
      ),
585
  };
586
}
587

588
Widget _buildFittedBox(ElementPropertyView model) {
4✔
589
  return switch (model.controlled) {
4✔
590
    true => DuitControlledFittedBox(
8✔
591
        controller: model.viewController,
4✔
592
        child: _buildWidget(model.child),
8✔
593
      ),
594
    false => DuitFittedBox(
8✔
595
        attributes: model.attributes,
4✔
596
        child: _buildWidget(model.child),
8✔
597
      ),
598
  };
599
}
600

601
Widget _buildPhysicalModel(ElementPropertyView model) {
4✔
602
  return switch (model.controlled) {
4✔
603
    true => DuitControlledPhysicalModel(
8✔
604
        controller: model.viewController,
4✔
605
        child: _buildWidget(model.child),
8✔
606
      ),
607
    false => DuitPhysicalModel(
8✔
608
        attributes: model.attributes,
4✔
609
        child: _buildWidget(model.child),
8✔
610
      ),
611
  };
612
}
613

614
Widget _buildFlexibleSpaceBar(ElementPropertyView model) {
4✔
615
  final children = _mapToNullableWidgetList(model);
4✔
616

617
  return switch (model.controlled) {
4✔
618
    true => DuitControlledFlexibleSpaceBar(
8✔
619
        controller: model.viewController,
4✔
620
        children: children,
621
      ),
622
    false => DuitFlexibleSpaceBar(
8✔
623
        attributes: model.attributes,
4✔
624
        children: children,
625
      ),
626
  };
627
}
628

629
Widget _buildSliverPadding(ElementPropertyView model) {
8✔
630
  return switch (model.controlled) {
8✔
631
    true => DuitControlledSliverPadding(
12✔
632
        controller: model.viewController,
4✔
633
        child: _buildWidget(model.child),
8✔
634
      ),
635
    false => DuitSliverPadding(
16✔
636
        attributes: model.attributes,
8✔
637
        child: _buildWidget(model.child),
16✔
638
      ),
639
  };
640
}
641

642
Widget _buildCustomScrollView(ElementPropertyView model) {
56✔
643
  return switch (model.controlled) {
56✔
644
    true => DuitControlledCustomScrollView(
64✔
645
        controller: model.viewController,
8✔
646
        children: model.children.map(_buildWidget).toList(),
24✔
647
      ),
648
    false => DuitCustomScrollView(
112✔
649
        attributes: model.attributes,
56✔
650
        children: model.children.map(_buildWidget).toList(),
168✔
651
      ),
652
  };
653
}
654

655
Widget _buildSliverFillRemaining(ElementPropertyView model) {
4✔
656
  return switch (model.controlled) {
4✔
657
    true => DuitControlledSliverFillRemaining(
8✔
658
        controller: model.viewController,
4✔
659
        child: _buildWidget(model.child),
8✔
660
      ),
661
    false => DuitSliverFillRemaining(
8✔
662
        attributes: model.attributes,
4✔
663
        child: _buildWidget(model.child),
8✔
664
      ),
665
  };
666
}
667

668
// SliverToBoxAdapter is not a standalone widget - it's used internally by other slivers
669
Widget _buildSliverToBoxAdapter(ElementPropertyView model) =>
12✔
670
    SliverToBoxAdapter(
12✔
671
      child: _buildWidget(model.child),
24✔
672
    );
673

674
Widget _buildSliverFillViewport(ElementPropertyView model) {
4✔
675
  return switch (model.controlled) {
4✔
676
    true => DuitControlledSliverFillViewport(
8✔
677
        controller: model.viewController,
4✔
678
        children: model.children.map(_buildWidget).toList(),
12✔
679
      ),
680
    false => DuitSliverFillViewport(
8✔
681
        attributes: model.attributes,
4✔
682
        children: model.children.map(_buildWidget).toList(),
12✔
683
      ),
684
  };
685
}
686

687
Widget _buildSliverOpacity(ElementPropertyView model) {
4✔
688
  return switch (model.controlled) {
4✔
689
    true => DuitControlledSliverOpacity(
8✔
690
        controller: model.viewController,
4✔
691
        child: _buildWidget(model.child),
8✔
692
      ),
693
    false => DuitSliverOpacity(
8✔
694
        attributes: model.attributes,
4✔
695
        child: _buildWidget(model.child),
8✔
696
      ),
697
  };
698
}
699

700
Widget _buildSliverVisibility(ElementPropertyView model) {
4✔
701
  final arr = model.children;
4✔
702
  // SliverVisibility widget expects two children: sliver and replacementSliver
703
  // This is necessary because the replacementSliver parameter requires a non-nullable widget
704
  final children = List<Widget>.generate(2, (index) {
8✔
705
    final child = arr.elementAtOrNull(index);
4✔
706
    return child == null ? const SliverToBoxAdapter() : _buildWidget(child);
4✔
707
  });
708

709
  return switch (model.controlled) {
4✔
710
    true => DuitControlledSliverVisibility(
8✔
711
        controller: model.viewController,
4✔
712
        children: children,
713
      ),
714
    false => DuitSliverVisibility(
8✔
715
        attributes: model.attributes,
4✔
716
        children: children,
717
      ),
718
  };
719
}
720

721
Widget _buildSliverAnimatedOpacity(ElementPropertyView model) =>
4✔
722
    DuitSliverAnimatedOpacity(
4✔
723
      controller: model.viewController,
4✔
724
      child: _buildWidget(model.child),
8✔
725
    );
726

727
Widget _buildSliverOffstage(ElementPropertyView model) {
4✔
728
  return switch (model.controlled) {
4✔
729
    true => DuitControlledSliverOffstage(
8✔
730
        controller: model.viewController,
4✔
731
        child: _buildWidget(model.child),
8✔
732
      ),
733
    false => DuitSliverOffstage(
8✔
734
        attributes: model.attributes,
4✔
735
        child: _buildWidget(model.child),
8✔
736
      ),
737
  };
738
}
739

740
Widget _buildSliverIgnorePointer(ElementPropertyView model) {
4✔
741
  return switch (model.controlled) {
4✔
742
    true => DuitControlledSliverIgnorePointer(
8✔
743
        controller: model.viewController,
4✔
744
        child: _buildWidget(model.child),
8✔
745
      ),
746
    false => DuitSliverIgnorePointer(
8✔
747
        attributes: model.attributes,
4✔
748
        child: _buildWidget(model.child),
8✔
749
      ),
750
  };
751
}
752

753
Widget _buildSliverSafeArea(ElementPropertyView model) {
4✔
754
  return switch (model.controlled) {
4✔
755
    true => DuitControlledSliverSafeArea(
8✔
756
        controller: model.viewController,
4✔
757
        child: _buildWidget(model.child),
8✔
758
      ),
759
    false => DuitSliverSafeArea(
8✔
760
        attributes: model.attributes,
4✔
761
        child: _buildWidget(model.child),
8✔
762
      ),
763
  };
764
}
765

766
Widget _buildSliverAppBar(ElementPropertyView model) {
4✔
767
  final children = _mapToNullableWidgetList(model);
4✔
768

769
  return switch (model.controlled) {
4✔
770
    true => DuitControlledSliverAppBar(
8✔
771
        controller: model.viewController,
4✔
772
        children: children,
773
      ),
774
    false => DuitSliverAppBar(
×
775
        attributes: model.attributes,
×
776
        children: children,
777
      ),
778
  };
779
}
780

781
Widget _buildComponent(ElementPropertyView model) => DuitComponent(
40✔
782
      controller: model.viewController,
20✔
783
      child: _buildWidget(model.child),
40✔
784
    );
785

786
Widget _buildListView(ElementPropertyView model) {
4✔
787
  int widgetType;
788

789
  if (!model.controlled) {
4✔
790
    widgetType = model.attributes.payload.getInt(key: "type");
12✔
791
  } else {
792
    widgetType = model.viewController.attributes.payload.getInt(key: "type");
16✔
793
  }
794

795
  switch (widgetType) {
796
    case 0:
4✔
797
      return model.controlled
4✔
798
          ? DuitControlledListView(
4✔
799
              controller: model.viewController,
4✔
800
              children: model.children.map(_buildWidget).toList(),
12✔
801
            )
802
          : DuitListView(
4✔
803
              attributes: model.attributes,
4✔
804
              children: model.children.map(_buildWidget).toList(),
12✔
805
            );
806
    case 1:
4✔
807
      return DuitListViewBuilder(
4✔
808
        controller: model.viewController,
4✔
809
      );
810
    case 2:
4✔
811
      return DuitListViewSeparated(
4✔
812
        controller: model.viewController,
4✔
813
      );
814
    default:
815
      return const SizedBox.shrink();
816
  }
817
}
818

819
Widget _buildGridView(ElementPropertyView model) {
4✔
820
  GridConstructor widgetType;
821

822
  if (!model.controlled) {
4✔
823
    widgetType = GridConstructor.fromValue(
4✔
824
      model.attributes.payload.getString(key: "constructor"),
12✔
825
    );
826
  } else {
827
    widgetType = GridConstructor.fromValue(
4✔
828
      model.viewController.attributes.payload.getString(key: "constructor"),
16✔
829
    );
830
  }
831

832
  switch (widgetType) {
833
    case GridConstructor.common:
4✔
834
    case GridConstructor.count:
4✔
835
    case GridConstructor.extent:
4✔
836
      if (!model.controlled) {
4✔
837
        return DuitGridView(
4✔
838
          constructor: widgetType,
839
          attributes: model.attributes,
4✔
840
          children: model.children.map(_buildWidget).toList(),
12✔
841
        );
842
      } else {
843
        return DuitControlledGridView(
4✔
844
          constructor: widgetType,
845
          controller: model.viewController,
4✔
846
          children: model.children.map(_buildWidget).toList(),
12✔
847
        );
848
      }
UNCOV
849
    case GridConstructor.builder:
×
UNCOV
850
      return DuitGridBuilder(
×
UNCOV
851
        controller: model.viewController,
×
852
      );
853
  }
854
}
855

856
Widget _buildPageView(ElementPropertyView model) {
4✔
857
  PageViewConstructor widgetType;
858
  final isControlled = model.controlled;
4✔
859

860
  if (!isControlled) {
861
    widgetType = PageViewConstructor.fromValue(
4✔
862
      model.attributes.payload.getString(key: "constructor"),
12✔
863
    );
864
  } else {
865
    widgetType = PageViewConstructor.fromValue(
4✔
866
      model.viewController.attributes.payload.getString(key: "constructor"),
16✔
867
    );
868
  }
869

870
  switch (widgetType) {
871
    case PageViewConstructor.common:
4✔
872
      if (!isControlled) {
873
        return DuitPageViewCommon(
4✔
874
          attributes: model.attributes,
4✔
875
          children: model.children.map(_buildWidget).toList(),
12✔
876
        );
877
      } else {
878
        return DuitControlledPageViewCommon(
4✔
879
          controller: model.viewController,
4✔
880
          children: model.children.map(_buildWidget).toList(),
12✔
881
        );
882
      }
883
    case PageViewConstructor.builder:
4✔
884
      return DuitPageViewBuilder(
4✔
885
        controller: model.viewController,
4✔
886
      );
887
  }
888
}
889

890
Widget _buildCarouselView(ElementPropertyView model) {
4✔
891
  return switch (model.controlled) {
4✔
892
    true => DuitControlledCarouselView(
8✔
893
        controller: model.viewController,
4✔
894
        children: model.children.map(_buildWidget).toList(),
12✔
895
      ),
896
    false => DuitCarouselView(
8✔
897
        attributes: model.attributes,
4✔
898
        children: model.children.map(_buildWidget).toList(),
12✔
899
      ),
900
  };
901
}
902

903
Widget _buildSliverList(ElementPropertyView model) {
4✔
904
  int widgetType;
905

906
  if (!model.controlled) {
4✔
907
    widgetType = model.attributes.payload.getInt(key: "type");
12✔
908
  } else {
909
    widgetType = model.viewController.attributes.payload.getInt(key: "type");
16✔
910
  }
911

912
  switch (widgetType) {
913
    case 0:
4✔
914
      return model.controlled
4✔
915
          ? DuitControlledSliverList(
4✔
916
              controller: model.viewController,
4✔
917
              children: model.children.map(_buildWidget).toList(),
12✔
918
            )
919
          : DuitSliverList(
4✔
920
              attributes: model.attributes,
4✔
921
              children: model.children.map(_buildWidget).toList(),
12✔
922
            );
923
    case 1:
4✔
924
      return DuitSliverListBuilder(
4✔
925
        controller: model.viewController,
4✔
926
      );
927
    case 2:
4✔
928
      return DuitSliverListSeparated(
4✔
929
        controller: model.viewController,
4✔
930
      );
931
    default:
932
      return const SizedBox.shrink();
933
  }
934
}
935

936
Widget _buildSliverGrid(ElementPropertyView model) {
4✔
937
  GridConstructor widgetType;
938

939
  if (!model.controlled) {
4✔
940
    widgetType = GridConstructor.fromValue(
4✔
941
      model.attributes.payload.getString(key: "constructor"),
12✔
942
    );
943
  } else {
944
    widgetType = GridConstructor.fromValue(
4✔
945
      model.viewController.attributes.payload.getString(key: "constructor"),
16✔
946
    );
947
  }
948

949
  switch (widgetType) {
950
    case GridConstructor.common:
4✔
951
    case GridConstructor.count:
4✔
952
    case GridConstructor.extent:
4✔
953
      if (!model.controlled) {
4✔
954
        return DuitSliverGrid(
4✔
955
          constructor: widgetType,
956
          attributes: model.attributes,
4✔
957
          children: model.children.map(_buildWidget).toList(),
12✔
958
        );
959
      } else {
960
        return DuitControlledSliverGrid(
4✔
961
          constructor: widgetType,
962
          controller: model.viewController,
4✔
963
          children: model.children.map(_buildWidget).toList(),
12✔
964
        );
965
      }
966
    case GridConstructor.builder:
4✔
967
      return DuitSliverGridBuilder(
4✔
968
        controller: model.viewController,
4✔
969
      );
970
  }
971
}
972

973
Widget _buildWrap(ElementPropertyView model) {
4✔
974
  return switch (model.controlled) {
4✔
975
    true => DuitControlledWrap(
8✔
976
        controller: model.viewController,
4✔
977
        children: model.children.map(_buildWidget).toList(),
12✔
978
      ),
979
    false => DuitWrap(
8✔
980
        attributes: model.attributes,
4✔
981
        children: model.children.map(_buildWidget).toList(),
12✔
982
      ),
983
  };
984
}
985

986
Widget _buildBadge(ElementPropertyView model) {
4✔
987
  final children = _mapToNullableWidgetList(model);
4✔
988
  return switch (model.controlled) {
4✔
989
    true => DuitControlledBadge(
8✔
990
        controller: model.viewController,
4✔
991
        children: children,
992
      ),
993
    false => DuitBadge(
8✔
994
        attributes: model.attributes,
4✔
995
        children: children,
996
      )
997
  };
998
}
999

1000
Widget _buildCustomWidget(DuitElement model) {
4✔
1001
  final tag = model.tag;
4✔
1002
  if (tag == null) return const SizedBox.shrink();
1003

1004
  final element = model.element;
4✔
1005
  final children = element.containsKey("children")
4✔
1006
      ? (element["children"] as List).map(_buildWidget).toList()
12✔
1007
      : <Widget>[];
4✔
1008

1009
  final builder = DuitRegistry.getBuildFactory(tag);
4✔
1010
  return builder?.call(model, children) ?? const SizedBox.shrink();
4✔
1011
}
1012

1013
Widget _buildWidget(widgetModel) {
336✔
1014
  return switch (widgetModel) {
1015
    DuitElement() => _buildFromElementPropertyView(widgetModel.element),
1,008✔
1016
    ElementPropertyView() => _buildFromElementPropertyView(widgetModel),
584✔
1017
    _ => const SizedBox.shrink(),
1018
  };
1019
}
1020

1021
Widget _buildFromElementPropertyView(ElementPropertyView model) {
336✔
1022
  // Support rendering of Custom widgets at any level in the tree
1023
  if (model.type == ElementType.custom) {
672✔
1024
    return _buildCustomWidget(DuitElement.wrap(model));
8✔
1025
  }
1026

1027
  final buildFn = _buildFnLookup[model.type];
672✔
1028

1029
  if (buildFn != null) {
1030
    return buildFn(model);
336✔
1031
  } else if (throwOnUnspecifiedWidgetType) {
1032
    throw ArgumentError("Unspecified widget type: ${model.type}");
12✔
1033
  } else {
1034
    return const SizedBox.shrink();
1035
  }
1036
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc