1
1
import 'package:flutter/cupertino.dart' ;
2
- import 'package:flutter/material.dart' show Colors;
3
2
import 'package:flutter/widgets.dart' ;
4
3
import 'package:flutter_test/flutter_test.dart' ;
5
4
import 'package:flutter_test_goldens/flutter_test_goldens.dart' ;
@@ -59,6 +58,25 @@ class GridGoldenScene extends StatelessWidget {
59
58
60
59
@override
61
60
Widget build (BuildContext context) {
61
+ return DefaultTextStyle (
62
+ style: GoldenSceneTheme .current.defaultTextStyle,
63
+ child: GoldenSceneBounds (
64
+ child: Stack (
65
+ children: [
66
+ Positioned .fill (
67
+ child: _buildBackground (context),
68
+ ),
69
+ Padding (
70
+ padding: spacing.around,
71
+ child: _buildGoldens (),
72
+ ),
73
+ ],
74
+ ),
75
+ ),
76
+ );
77
+ }
78
+
79
+ Widget _buildGoldens () {
62
80
final entries = goldens.entries.toList ();
63
81
64
82
final rows = < TableRow > [];
@@ -77,16 +95,18 @@ class GridGoldenScene extends StatelessWidget {
77
95
top: row > 0 ? defaultGridSpacing.between : 0 ,
78
96
left: col > 0 ? defaultGridSpacing.between : 0 ,
79
97
),
80
- child: _buildItem (
81
- context,
82
- entries[index].key.metadata,
83
- Image .memory (
84
- key: entries[index].value,
85
- entries[index].key.pngBytes,
86
- width: entries[index].key.size.width,
87
- height: entries[index].key.size.height,
88
- ),
89
- ),
98
+ child: Builder (builder: (context) {
99
+ return _decorator (
100
+ context,
101
+ entries[index].key.metadata,
102
+ Image .memory (
103
+ key: entries[index].value,
104
+ entries[index].key.pngBytes,
105
+ width: entries[index].key.size.width,
106
+ height: entries[index].key.size.height,
107
+ ),
108
+ );
109
+ }),
90
110
),
91
111
);
92
112
}
@@ -98,28 +118,18 @@ class GridGoldenScene extends StatelessWidget {
98
118
);
99
119
}
100
120
101
- return DefaultTextStyle (
102
- style: GoldenSceneTheme .current.defaultTextStyle,
103
- child: GoldenSceneBounds (
104
- child: ColoredBox (
105
- color: Colors .white,
106
- child: Padding (
107
- padding: spacing.around,
108
- child: Table (
109
- defaultColumnWidth: IntrinsicColumnWidth (),
110
- children: rows,
111
- ),
112
- ),
113
- ),
114
- ),
121
+ return Table (
122
+ defaultColumnWidth: IntrinsicColumnWidth (),
123
+ children: rows,
115
124
);
116
125
}
117
126
118
- Widget _buildItem (BuildContext context, GoldenScreenshotMetadata metadata, Widget content ) {
119
- if ( itemDecorator == null ) {
120
- return content ;
121
- }
127
+ Widget _decorator (BuildContext context, GoldenScreenshotMetadata metadata, Widget child ) {
128
+ final itemDecorator = this .itemDecorator ?? GoldenSceneTheme .current.itemDecorator;
129
+ return itemDecorator (context, metadata, child) ;
130
+ }
122
131
123
- return itemDecorator !(context, metadata, content);
132
+ Widget _buildBackground (BuildContext context) {
133
+ return (background ?? GoldenSceneTheme .current.background).build (context);
124
134
}
125
135
}
0 commit comments