I am new with Flutter, I am trying to open camera, for this I followed example code but when ever I debug my app it gives me Exception as shown in image
Here's my code:
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:camera/camera.dart';
import 'home.dart';
List<CameraDescription> cameras;
Future<Null> main() async {
try {
cameras = await availableCameras();
} on CameraException catch (e) {
print('Error: $e.code\nError Message: $e.message');
}
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'RealTime Detection',
home: HomePage(cameras),
);
}
}