onInit method

  1. @override
void onInit()
override

Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.

Implementation

@override
void onInit() async {
  super.onInit();

  await _luxand.initialize();
  await initCamera();

  camController!.initialize().then((_) {
    isCameraReady.value = true;
    previewScale = getCameraPreviewScale(camController!.value.aspectRatio);

    // Only open and close camera in iOS for low-tier device
    if (Platform.isIOS) {
      // _timer = Stream.periodic(const Duration(milliseconds: 500), (v) => v)
      //     .listen((count) async {
      //   _throttler.run(() async {
      //     controller.startImageStream((image) async {});

      //     Future.delayed(const Duration(milliseconds: 50), () async {
      //       await controller.stopImageStream();
      //     });
      //   });
      // });
    } else {
      camController!.startImageStream(_handleCameraAndroid);
    }
  });
}