Skip to content

Commit 9aca01e

Browse files
committed
changed loop render the BoxFit enum.
1 parent 3886a3d commit 9aca01e

File tree

1 file changed

+14
-27
lines changed

1 file changed

+14
-27
lines changed

example/lib/barcode_scanner_window.dart

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,8 @@ class _BarcodeScannerWithScanWindowState
104104
spacing: 0.5,
105105
runSpacing: 3.0,
106106
alignment: WrapAlignment.center,
107-
children: BoxFitOption.values.map((option) {
108-
return SizedBox(
109-
height: 28,
110-
child: ElevatedButton(
111-
onPressed: () {
112-
setState(() {
113-
boxFit = option.boxFit;
114-
});
115-
},
116-
child: Text(option.label),
117-
),
118-
);
107+
children: BoxFit.values.map((fit) {
108+
return _buildBoxFitButton(fit);
119109
}).toList(),
120110
),
121111
),
@@ -129,24 +119,21 @@ class _BarcodeScannerWithScanWindowState
129119
);
130120
}
131121

122+
Widget _buildBoxFitButton(BoxFit fit) {
123+
return SizedBox(
124+
height: 28,
125+
child: ElevatedButton(
126+
onPressed: () => setState(() {
127+
boxFit = fit;
128+
}),
129+
child: Text(fit.name),
130+
),
131+
);
132+
}
133+
132134
@override
133135
Future<void> dispose() async {
134136
super.dispose();
135137
await controller.dispose();
136138
}
137139
}
138-
139-
enum BoxFitOption {
140-
fill(BoxFit.fill, "fill"),
141-
contain(BoxFit.contain, "contain"),
142-
cover(BoxFit.cover, "cover"),
143-
fitWidth(BoxFit.fitWidth, "fitWidth"),
144-
fitHeight(BoxFit.fitHeight, "fitHeight"),
145-
none(BoxFit.none, "none"),
146-
scaleDown(BoxFit.scaleDown, "scaleDown");
147-
148-
final BoxFit boxFit;
149-
final String label;
150-
151-
const BoxFitOption(this.boxFit, this.label);
152-
}

0 commit comments

Comments
 (0)