File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import 'dart:async';
6
6
import 'dart:io' ;
7
7
8
8
import 'package:flutter/material.dart' ;
9
+ import 'package:flutter/scheduler.dart' ;
9
10
import 'package:flutter/services.dart' ;
10
11
import 'package:camera/camera.dart' ;
11
12
import 'package:path_provider/path_provider.dart' ;
@@ -244,14 +245,28 @@ class CameraPickerState extends State<CameraPicker> {
244
245
if (Platform .isIOS) {
245
246
SystemChrome .setEnabledSystemUIOverlays (< SystemUiOverlay > []);
246
247
}
247
- initStorePath ();
248
- initCameras ();
248
+
249
+ try {
250
+ initStorePath ();
251
+ initCameras ();
252
+ } catch (e) {
253
+ realDebugPrint ('Error when initializing: $e ' );
254
+ if (context == null ) {
255
+ SchedulerBinding .instance.addPostFrameCallback ((Duration _) {
256
+ Navigator .of (context).pop ();
257
+ });
258
+ } else {
259
+ Navigator .of (context).pop ();
260
+ }
261
+ }
249
262
}
250
263
251
264
@override
252
265
void dispose () {
253
266
SystemChrome .setEnabledSystemUIOverlays (SystemUiOverlay .values);
254
267
cameraController? .dispose ();
268
+ recordDetectTimer? .cancel ();
269
+ recordCountdownTimer? .cancel ();
255
270
super .dispose ();
256
271
}
257
272
You can’t perform that action at this time.
0 commit comments