when I compiled my app the error{LateInitializationError: Field 'contorller' has not been initialized} appeared and when I changed the Late keyword with ? operator and Put ! before the methods that depends on the variable like stackoverflow suggests another error appeared {Null check operator used on a null value} so how can I solved that
itis a statful class
class _MyHomePageState extends State<MyHomePage> {
BarcodeDetector ?labeler;
CameraController? controller;
bool isBusy = false;
String result = "";
File ?_image;
ImagePicker ?imagePicker;
CameraImage ?img;
void initState() {
super.initState();
labeler = FirebaseVision.instance.barcodeDetector();
}
intializeCamera() async {
controller = CameraController(cameras[0], ResolutionPreset.medium);
await controller!.initialize().then((_) {
if (!mounted) {
return;
}
controller!.startImageStream((image) => {
if (!isBusy) {isBusy = true, img = image, doBarcodeScanning()}
});
});
}
void dispose() {
controller!.dispose();
labeler!.close();
super.dispose();
}
Center(
child: Container(
margin: EdgeInsets.only(top: 100),
height: 220,
width: 220,
child: AspectRatio(
aspectRatio: controller!.value.aspectRatio,
child: CameraPreview(controller),
),
),
),