@@ -104,18 +104,8 @@ class _BarcodeScannerWithScanWindowState
104
104
spacing: 0.5 ,
105
105
runSpacing: 3.0 ,
106
106
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);
119
109
}).toList (),
120
110
),
121
111
),
@@ -129,24 +119,21 @@ class _BarcodeScannerWithScanWindowState
129
119
);
130
120
}
131
121
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
+
132
134
@override
133
135
Future <void > dispose () async {
134
136
super .dispose ();
135
137
await controller.dispose ();
136
138
}
137
139
}
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