-
-
Notifications
You must be signed in to change notification settings - Fork 678
Expand file tree
/
Copy pathcamera_screen.dart
More file actions
47 lines (40 loc) · 982 Bytes
/
camera_screen.dart
File metadata and controls
47 lines (40 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import 'package:flutter/material.dart';
import 'package:camera/camera.dart';
class CameraScreen extends StatefulWidget {
List<CameraDescription> cameras;
CameraScreen(this.cameras);
@override
CameraScreenState createState() {
return new CameraScreenState();
}
}
class CameraScreenState extends State<CameraScreen> {
CameraController controller;
@override
void initState() {
super.initState();
controller =
new CameraController(widget.cameras[0], ResolutionPreset.medium);
controller.initialize().then((_) {
if (!mounted) {
return;
}
setState(() {});
});
}
@override
void dispose() {
controller?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (!controller.value.isInitialized) {
return new Container();
}
return new AspectRatio(
aspectRatio: controller.value.aspectRatio,
child: new CameraPreview(controller),
);
}
}