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

Duit-Foundation / flutter_duit / 19115039532

05 Nov 2025 08:15PM UTC coverage: 86.358% (+8.9%) from 77.409%
19115039532

push

github

web-flow
major: flutter_duit v4 (#310)

2151 of 2405 new or added lines in 109 files covered. (89.44%)

36 existing lines in 7 files now uncovered.

3773 of 4369 relevant lines covered (86.36%)

35.87 hits per line

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

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

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

10
Widget _buildText(ElementPropertyView model) {
144✔
11
  return switch (model.controlled) {
144✔
12
    true => DuitControlledText(controller: model.viewController),
224✔
13
    false => DuitText(attributes: model.attributes),
372✔
14
  };
15
}
16

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

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

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

50
Widget _buildTextField(ElementPropertyView model) => DuitTextField(
16✔
51
      controller: model.viewController,
8✔
52
    );
53

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

296
Widget _buildAnimatedBuilder(ElementPropertyView model) => DuitAnimatedBuilder(
16✔
297
      controller: model.viewController,
8✔
298
      child: _buildWidget(model.child),
16✔
299
    );
300

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

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

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

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

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

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

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

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

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

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

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

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

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

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

400
// Single child widgets with controlled/non-controlled versions
401
Widget _buildIntrinsicHeight(ElementPropertyView model) {
4✔
402
  return switch (model.controlled) {
4✔
403
    true => DuitControlledIntrinsicHeight(
8✔
404
        controller: model.viewController,
4✔
405
        child: _buildWidget(model.child),
8✔
406
      ),
407
    false => DuitIntrinsicHeight(
8✔
408
        attributes: model.attributes,
4✔
409
        child: _buildWidget(model.child),
8✔
410
      ),
411
  };
412
}
413

414
Widget _buildIntrinsicWidth(ElementPropertyView model) {
4✔
415
  return switch (model.controlled) {
4✔
416
    true => DuitControlledIntrinsicWidth(
8✔
417
        controller: model.viewController,
4✔
418
        child: _buildWidget(model.child),
8✔
419
      ),
420
    false => DuitIntrinsicWidth(
8✔
421
        attributes: model.attributes,
4✔
422
        child: _buildWidget(model.child),
8✔
423
      ),
424
  };
425
}
426

427
Widget _buildRotatedBox(ElementPropertyView model) {
4✔
428
  return switch (model.controlled) {
4✔
429
    true => DuitControlledRotatedBox(
8✔
430
        controller: model.viewController,
4✔
431
        child: _buildWidget(model.child),
8✔
432
      ),
433
    false => DuitRotatedBox(
8✔
434
        attributes: model.attributes,
4✔
435
        child: _buildWidget(model.child),
8✔
436
      ),
437
  };
438
}
439

440
Widget _buildConstrainedBox(ElementPropertyView model) {
4✔
441
  return switch (model.controlled) {
4✔
442
    true => DuitControlledConstrainedBox(
8✔
443
        controller: model.viewController,
4✔
444
        child: _buildWidget(model.child),
8✔
445
      ),
446
    false => DuitConstrainedBox(
8✔
447
        attributes: model.attributes,
4✔
448
        child: _buildWidget(model.child),
8✔
449
      ),
450
  };
451
}
452

453
Widget _buildBackdropFilter(ElementPropertyView model) {
4✔
454
  return switch (model.controlled) {
4✔
455
    true => DuitControlledBackdropFilter(
4✔
NEW
456
        controller: model.viewController,
×
NEW
457
        child: _buildWidget(model.child),
×
458
      ),
459
    false => DuitBackdropFilter(
8✔
460
        attributes: model.attributes,
4✔
461
        child: _buildWidget(model.child),
8✔
462
      ),
463
  };
464
}
465

466
Widget _buildRemoteSubtree(ElementPropertyView model) => DuitRemoteSubtree(
8✔
467
      controller: model.viewController,
4✔
468
    );
469

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

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

496
Widget _buildExpanded(ElementPropertyView model) {
4✔
497
  return switch (model.controlled) {
4✔
498
    true => DuitControlledExpanded(
8✔
499
        controller: model.viewController,
4✔
500
        child: _buildWidget(model.child),
8✔
501
      ),
502
    false => DuitExpanded(
8✔
503
        attributes: model.attributes,
4✔
504
        child: _buildWidget(model.child),
8✔
505
      ),
506
  };
507
}
508

509
Widget _buildGestureDetector(ElementPropertyView model) => DuitGestureDetector(
8✔
510
      controller: model.viewController,
4✔
511
      child: _buildWidget(model.child),
8✔
512
    );
513

514
Widget _buildColoredBox(ElementPropertyView model) {
4✔
515
  return switch (model.controlled) {
4✔
516
    true => DuitControlledColoredBox(
8✔
517
        controller: model.viewController,
4✔
518
        child: _buildWidget(model.child),
8✔
519
      ),
520
    false => DuitColoredBox(
8✔
521
        attributes: model.attributes,
4✔
522
        child: _buildWidget(model.child),
8✔
523
      ),
524
  };
525
}
526

NEW
527
Widget _buildLifecycleStateListener(ElementPropertyView model) =>
×
NEW
528
    DuitLifecycleStateListener(
×
NEW
529
      controller: model.viewController,
×
NEW
530
      child: _buildWidget(model.child),
×
531
    );
532

533
Widget _buildIgnorePointer(ElementPropertyView model) {
4✔
534
  return switch (model.controlled) {
4✔
535
    true => DuitControlledIgnorePointer(
8✔
536
        controller: model.viewController,
4✔
537
        child: _buildWidget(model.child),
8✔
538
      ),
539
    false => DuitIgnorePointer(
8✔
540
        attributes: model.attributes,
4✔
541
        child: _buildWidget(model.child),
8✔
542
      ),
543
  };
544
}
545

546
Widget _buildOpacity(ElementPropertyView model) {
4✔
547
  return switch (model.controlled) {
4✔
548
    true => DuitControlledOpacity(
8✔
549
        controller: model.viewController,
4✔
550
        child: _buildWidget(model.child),
8✔
551
      ),
552
    false => DuitOpacity(
8✔
553
        attributes: model.attributes,
4✔
554
        child: _buildWidget(model.child),
8✔
555
      ),
556
  };
557
}
558

559
Widget _buildFittedBox(ElementPropertyView model) {
4✔
560
  return switch (model.controlled) {
4✔
561
    true => DuitControlledFittedBox(
8✔
562
        controller: model.viewController,
4✔
563
        child: _buildWidget(model.child),
8✔
564
      ),
565
    false => DuitFittedBox(
8✔
566
        attributes: model.attributes,
4✔
567
        child: _buildWidget(model.child),
8✔
568
      ),
569
  };
570
}
571

572
Widget _buildPhysicalModel(ElementPropertyView model) {
4✔
573
  return switch (model.controlled) {
4✔
574
    true => DuitControlledPhysicalModel(
8✔
575
        controller: model.viewController,
4✔
576
        child: _buildWidget(model.child),
8✔
577
      ),
578
    false => DuitPhysicalModel(
8✔
579
        attributes: model.attributes,
4✔
580
        child: _buildWidget(model.child),
8✔
581
      ),
582
  };
583
}
584

585
Widget _buildFlexibleSpaceBar(ElementPropertyView model) {
4✔
586
  final children = _mapToNullableWidgetList(model);
4✔
587

588
  return switch (model.controlled) {
4✔
589
    true => DuitControlledFlexibleSpaceBar(
8✔
590
        controller: model.viewController,
4✔
591
        children: children,
592
      ),
593
    false => DuitFlexibleSpaceBar(
8✔
594
        attributes: model.attributes,
4✔
595
        children: children,
596
      ),
597
  };
598
}
599

600
Widget _buildSliverPadding(ElementPropertyView model) {
8✔
601
  return switch (model.controlled) {
8✔
602
    true => DuitControlledSliverPadding(
12✔
603
        controller: model.viewController,
4✔
604
        child: _buildWidget(model.child),
8✔
605
      ),
606
    false => DuitSliverPadding(
16✔
607
        attributes: model.attributes,
8✔
608
        child: _buildWidget(model.child),
16✔
609
      ),
610
  };
611
}
612

613
Widget _buildCustomScrollView(ElementPropertyView model) {
56✔
614
  return switch (model.controlled) {
56✔
615
    true => DuitControlledCustomScrollView(
64✔
616
        controller: model.viewController,
8✔
617
        children: model.children.map(_buildWidget).toList(),
24✔
618
      ),
619
    false => DuitCustomScrollView(
112✔
620
        attributes: model.attributes,
56✔
621
        children: model.children.map(_buildWidget).toList(),
168✔
622
      ),
623
  };
624
}
625

626
Widget _buildSliverFillRemaining(ElementPropertyView model) {
4✔
627
  return switch (model.controlled) {
4✔
628
    true => DuitControlledSliverFillRemaining(
8✔
629
        controller: model.viewController,
4✔
630
        child: _buildWidget(model.child),
8✔
631
      ),
632
    false => DuitSliverFillRemaining(
8✔
633
        attributes: model.attributes,
4✔
634
        child: _buildWidget(model.child),
8✔
635
      ),
636
  };
637
}
638

639
// SliverToBoxAdapter is not a standalone widget - it's used internally by other slivers
640
Widget _buildSliverToBoxAdapter(ElementPropertyView model) =>
12✔
641
    SliverToBoxAdapter(
12✔
642
      child: _buildWidget(model.child),
24✔
643
    );
644

645
Widget _buildSliverFillViewport(ElementPropertyView model) {
4✔
646
  return switch (model.controlled) {
4✔
647
    true => DuitControlledSliverFillViewport(
8✔
648
        controller: model.viewController,
4✔
649
        children: model.children.map(_buildWidget).toList(),
12✔
650
      ),
651
    false => DuitSliverFillViewport(
8✔
652
        attributes: model.attributes,
4✔
653
        children: model.children.map(_buildWidget).toList(),
12✔
654
      ),
655
  };
656
}
657

658
Widget _buildSliverOpacity(ElementPropertyView model) {
4✔
659
  return switch (model.controlled) {
4✔
660
    true => DuitControlledSliverOpacity(
8✔
661
        controller: model.viewController,
4✔
662
        child: _buildWidget(model.child),
8✔
663
      ),
664
    false => DuitSliverOpacity(
8✔
665
        attributes: model.attributes,
4✔
666
        child: _buildWidget(model.child),
8✔
667
      ),
668
  };
669
}
670

671
Widget _buildSliverVisibility(ElementPropertyView model) {
4✔
672
  final arr = model.children;
4✔
673
  // SliverVisibility widget expects two children: sliver and replacementSliver
674
  // This is necessary because the replacementSliver parameter requires a non-nullable widget
675
  final children = List<Widget>.generate(2, (index) {
8✔
676
    final child = arr.elementAtOrNull(index);
4✔
677
    return child == null ? const SliverToBoxAdapter() : _buildWidget(child);
4✔
678
  });
679

680
  return switch (model.controlled) {
4✔
681
    true => DuitControlledSliverVisibility(
8✔
682
        controller: model.viewController,
4✔
683
        children: children,
684
      ),
685
    false => DuitSliverVisibility(
8✔
686
        attributes: model.attributes,
4✔
687
        children: children,
688
      ),
689
  };
690
}
691

692
Widget _buildSliverAnimatedOpacity(ElementPropertyView model) =>
4✔
693
    DuitSliverAnimatedOpacity(
4✔
694
      controller: model.viewController,
4✔
695
      child: _buildWidget(model.child),
8✔
696
    );
697

698
Widget _buildSliverOffstage(ElementPropertyView model) {
4✔
699
  return switch (model.controlled) {
4✔
700
    true => DuitControlledSliverOffstage(
8✔
701
        controller: model.viewController,
4✔
702
        child: _buildWidget(model.child),
8✔
703
      ),
704
    false => DuitSliverOffstage(
8✔
705
        attributes: model.attributes,
4✔
706
        child: _buildWidget(model.child),
8✔
707
      ),
708
  };
709
}
710

711
Widget _buildSliverIgnorePointer(ElementPropertyView model) {
4✔
712
  return switch (model.controlled) {
4✔
713
    true => DuitControlledSliverIgnorePointer(
8✔
714
        controller: model.viewController,
4✔
715
        child: _buildWidget(model.child),
8✔
716
      ),
717
    false => DuitSliverIgnorePointer(
8✔
718
        attributes: model.attributes,
4✔
719
        child: _buildWidget(model.child),
8✔
720
      ),
721
  };
722
}
723

724
Widget _buildSliverSafeArea(ElementPropertyView model) {
4✔
725
  return switch (model.controlled) {
4✔
726
    true => DuitControlledSliverSafeArea(
8✔
727
        controller: model.viewController,
4✔
728
        child: _buildWidget(model.child),
8✔
729
      ),
730
    false => DuitSliverSafeArea(
8✔
731
        attributes: model.attributes,
4✔
732
        child: _buildWidget(model.child),
8✔
733
      ),
734
  };
735
}
736

737
Widget _buildSliverAppBar(ElementPropertyView model) {
4✔
738
  final children = _mapToNullableWidgetList(model);
4✔
739

740
  return switch (model.controlled) {
4✔
741
    true => DuitControlledSliverAppBar(
8✔
742
        controller: model.viewController,
4✔
743
        children: children,
744
      ),
NEW
745
    false => DuitSliverAppBar(
×
NEW
746
        attributes: model.attributes,
×
747
        children: children,
748
      ),
749
  };
750
}
751

752
Widget _buildComponent(ElementPropertyView model) => DuitComponent(
40✔
753
      controller: model.viewController,
20✔
754
      child: _buildWidget(model.child),
40✔
755
    );
756

757
Widget _buildListView(ElementPropertyView model) {
4✔
758
  int widgetType;
759

760
  if (!model.controlled) {
4✔
761
    widgetType = model.attributes.payload.getInt(key: "type");
12✔
762
  } else {
763
    widgetType = model.viewController.attributes.payload.getInt(key: "type");
16✔
764
  }
765

766
  switch (widgetType) {
767
    case 0:
4✔
768
      return model.controlled
4✔
769
          ? DuitControlledListView(
4✔
770
              controller: model.viewController,
4✔
771
              children: model.children.map(_buildWidget).toList(),
12✔
772
            )
773
          : DuitListView(
4✔
774
              attributes: model.attributes,
4✔
775
              children: model.children.map(_buildWidget).toList(),
12✔
776
            );
777
    case 1:
4✔
778
      return DuitListViewBuilder(
4✔
779
        controller: model.viewController,
4✔
780
      );
781
    case 2:
4✔
782
      return DuitListViewSeparated(
4✔
783
        controller: model.viewController,
4✔
784
      );
785
    default:
786
      return const SizedBox.shrink();
787
  }
788
}
789

790
Widget _buildGridView(ElementPropertyView model) {
4✔
791
  GridConstructor widgetType;
792

793
  if (!model.controlled) {
4✔
794
    widgetType = GridConstructor.fromValue(
4✔
795
      model.attributes.payload.getString(key: "constructor"),
12✔
796
    );
797
  } else {
798
    widgetType = GridConstructor.fromValue(
4✔
799
      model.viewController.attributes.payload.getString(key: "constructor"),
16✔
800
    );
801
  }
802

803
  switch (widgetType) {
804
    case GridConstructor.common:
4✔
805
    case GridConstructor.count:
4✔
806
    case GridConstructor.extent:
4✔
807
      if (!model.controlled) {
4✔
808
        return DuitGridView(
4✔
809
          constructor: widgetType,
810
          attributes: model.attributes,
4✔
811
          children: model.children.map(_buildWidget).toList(),
12✔
812
        );
813
      } else {
814
        return DuitControlledGridView(
4✔
815
          constructor: widgetType,
816
          controller: model.viewController,
4✔
817
          children: model.children.map(_buildWidget).toList(),
12✔
818
        );
819
      }
820
    case GridConstructor.builder:
4✔
821
      return DuitGridBuilder(
4✔
822
        controller: model.viewController,
4✔
823
      );
824
  }
825
}
826

827
Widget _buildCarouselView(ElementPropertyView model) {
4✔
828
  return switch (model.controlled) {
4✔
829
    true => DuitControlledCarouselView(
8✔
830
        controller: model.viewController,
4✔
831
        children: model.children.map(_buildWidget).toList(),
12✔
832
      ),
833
    false => DuitCarouselView(
8✔
834
        attributes: model.attributes,
4✔
835
        children: model.children.map(_buildWidget).toList(),
12✔
836
      ),
837
  };
838
}
839

840
Widget _buildSliverList(ElementPropertyView model) {
4✔
841
  int widgetType;
842

843
  if (!model.controlled) {
4✔
844
    widgetType = model.attributes.payload.getInt(key: "type");
12✔
845
  } else {
846
    widgetType = model.viewController.attributes.payload.getInt(key: "type");
16✔
847
  }
848

849
  switch (widgetType) {
850
    case 0:
4✔
851
      return model.controlled
4✔
852
          ? DuitControlledSliverList(
4✔
853
              controller: model.viewController,
4✔
854
              children: model.children.map(_buildWidget).toList(),
12✔
855
            )
856
          : DuitSliverList(
4✔
857
              attributes: model.attributes,
4✔
858
              children: model.children.map(_buildWidget).toList(),
12✔
859
            );
860
    case 1:
4✔
861
      return DuitSliverListBuilder(
4✔
862
        controller: model.viewController,
4✔
863
      );
864
    case 2:
4✔
865
      return DuitSliverListSeparated(
4✔
866
        controller: model.viewController,
4✔
867
      );
868
    default:
869
      return const SizedBox.shrink();
870
  }
871
}
872

873
Widget _buildSliverGrid(ElementPropertyView model) {
4✔
874
  GridConstructor widgetType;
875

876
  if (!model.controlled) {
4✔
877
    widgetType = GridConstructor.fromValue(
4✔
878
      model.attributes.payload.getString(key: "constructor"),
12✔
879
    );
880
  } else {
881
    widgetType = GridConstructor.fromValue(
4✔
882
      model.viewController.attributes.payload.getString(key: "constructor"),
16✔
883
    );
884
  }
885

886
  switch (widgetType) {
887
    case GridConstructor.common:
4✔
888
    case GridConstructor.count:
4✔
889
    case GridConstructor.extent:
4✔
890
      if (!model.controlled) {
4✔
891
        return DuitSliverGrid(
4✔
892
          constructor: widgetType,
893
          attributes: model.attributes,
4✔
894
          children: model.children.map(_buildWidget).toList(),
12✔
895
        );
896
      } else {
897
        return DuitControlledSliverGrid(
4✔
898
          constructor: widgetType,
899
          controller: model.viewController,
4✔
900
          children: model.children.map(_buildWidget).toList(),
12✔
901
        );
902
      }
903
    case GridConstructor.builder:
4✔
904
      return DuitSliverGridBuilder(
4✔
905
        controller: model.viewController,
4✔
906
      );
907
  }
908
}
909

910
Widget _buildWrap(ElementPropertyView model) {
4✔
911
  return switch (model.controlled) {
4✔
912
    true => DuitControlledWrap(
8✔
913
        controller: model.viewController,
4✔
914
        children: model.children.map(_buildWidget).toList(),
12✔
915
      ),
916
    false => DuitWrap(
8✔
917
        attributes: model.attributes,
4✔
918
        children: model.children.map(_buildWidget).toList(),
12✔
919
      ),
920
  };
921
}
922

923
Widget _buildCustomWidget(DuitElement model) {
4✔
924
  final tag = model.tag;
4✔
925
  if (tag == null) return const SizedBox.shrink();
926

927
  final element = model.element;
4✔
928
  final children = element.containsKey("children")
4✔
929
      ? (element["children"] as List).map(_buildWidget).toList()
12✔
930
      : <Widget>[];
4✔
931

932
  final builder = DuitRegistry.getBuildFactory(tag);
4✔
933
  return builder?.call(model, children) ?? const SizedBox.shrink();
4✔
934
}
935

936
Widget _buildWidget(widgetModel) {
316✔
937
  return switch (widgetModel) {
938
    DuitElement() => _buildFromElementPropertyView(widgetModel.element),
948✔
939
    ElementPropertyView() => _buildFromElementPropertyView(widgetModel),
536✔
940
    _ => const SizedBox.shrink(),
941
  };
942
}
943

944
Widget _buildFromElementPropertyView(ElementPropertyView model) {
316✔
945
  // Support rendering of Custom widgets at any level in the tree
946
  if (model.type == ElementType.custom) {
632✔
947
    return _buildCustomWidget(DuitElement.wrap(model));
8✔
948
  }
949

950
  final buildFn = _buildFnLookup[model.type];
632✔
951

952
  if (buildFn != null) {
953
    return buildFn(model);
316✔
954
  } else if (throwOnUnspecifiedWidgetType) {
955
    throw ArgumentError("Unspecified widget type: ${model.type}");
12✔
956
  } else {
957
    return const SizedBox.shrink();
958
  }
959
}
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