@@ -32,12 +32,14 @@ class Gallery {
32
32
BoxConstraints ? itemConstraints,
33
33
Finder ? itemBoundsFinder,
34
34
required SceneLayout layout,
35
+ GoldenSetup ? itemSetup,
35
36
}) : _fileName = fileName,
36
37
_sceneDescription = sceneDescription,
37
38
_itemScaffold = itemScaffold,
38
39
_itemConstraints = itemConstraints,
39
40
_itemBoundsFinder = itemBoundsFinder,
40
- _layout = layout {
41
+ _layout = layout,
42
+ _itemSetup = itemSetup {
41
43
_directory = directory ?? GoldenSceneTheme .current.directory;
42
44
}
43
45
@@ -84,6 +86,12 @@ class Gallery {
84
86
/// 3. `find.byType(GoldenImageBounds)` .
85
87
final Finder ? _itemBoundsFinder;
86
88
89
+ /// An optional setup method that runs after pumping an item's tree, and just before the
90
+ /// item is screenshotted.
91
+ ///
92
+ /// This setup runs for every item in the scene unless an individual item overrides it.
93
+ final GoldenSetup ? _itemSetup;
94
+
87
95
/// Requests for all screenshots within this scene, by their ID.
88
96
final _requests = < String , GalleryGoldenRequest > {};
89
97
@@ -353,7 +361,7 @@ class Gallery {
353
361
}
354
362
355
363
// Run the item's setup function, if there is one.
356
- await item.setup? .call (tester);
364
+ await ( item.setup ?? _itemSetup) ? .call (tester);
357
365
358
366
// Take a screenshot.
359
367
expect (item.boundsFinder, findsOne);
0 commit comments