File tree 2 files changed +14
-7
lines changed
lib/pages/computer_vision
2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,13 @@ class _LiveInferenceState extends State<LiveInference> {
84
84
});
85
85
}
86
86
87
+ void closeCamera () {
88
+ setState (() {
89
+ mode = LiveInferenceMode .image;
90
+ cameraDevice = null ;
91
+ });
92
+ }
93
+
87
94
@override
88
95
Widget build (BuildContext context) {
89
96
final theme = FluentTheme .of (context);
@@ -148,10 +155,7 @@ class _LiveInferenceState extends State<LiveInference> {
148
155
},
149
156
items: [
150
157
MenuFlyoutItem (text: const Text ("None" ), onPressed: () {
151
- setState (() {
152
- mode = LiveInferenceMode .image;
153
- cameraDevice = null ;
154
- });
158
+ closeCamera ();
155
159
}),
156
160
157
161
for (final device in devices)
Original file line number Diff line number Diff line change @@ -167,12 +167,12 @@ class CameraOptions extends StatefulWidget {
167
167
168
168
class _CameraOptionsState extends State <CameraOptions > {
169
169
170
- late Resolution resolution;
170
+ Resolution ? resolution;
171
171
172
172
@override
173
173
void initState () {
174
174
super .initState ();
175
- resolution = widget.device.resolutions.first ;
175
+ resolution = widget.device.resolutions.firstOrNull ;
176
176
}
177
177
178
178
void setResolution (Resolution res, ImageInferenceProvider inferenceProvider) {
@@ -197,13 +197,16 @@ class _CameraOptionsState extends State<CameraOptions> {
197
197
),
198
198
Builder (
199
199
builder: (context) {
200
+ if (widget.device.resolutions.isEmpty) {
201
+ return Container ();
202
+ }
200
203
return DropDownButton (
201
204
buttonBuilder: (context, callback) {
202
205
return NoOutlineButton (
203
206
onPressed: callback,
204
207
child: Row (
205
208
children: [
206
- Text ("Resolution: ${resolution .width } x ${resolution .height }" ),
209
+ Text ("Resolution: ${resolution ! .width } x ${resolution ! .height }" ),
207
210
const Padding (
208
211
padding: EdgeInsets .only (left: 8 ),
209
212
child: Icon (FluentIcons .chevron_down, size: 12 ),
You can’t perform that action at this time.
0 commit comments