Created
December 12, 2019 08:17
-
-
Save BoshiLee/aafa06e40bc8cafbcf7baff5d9e76b9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A screen that takes in a list of cameras and the Directory to store images. | |
class TakePictureScreen extends StatefulWidget { | |
final CameraDescription camera; | |
const TakePictureScreen({ | |
Key key, | |
@required this.camera, | |
}) : super(key: key); | |
@override | |
TakePictureScreenState createState() => TakePictureScreenState(); | |
} | |
class TakePictureScreenState extends State<TakePictureScreen> { | |
// Add two variables to the state class to store the CameraController and | |
// the Future. | |
CameraController _controller; | |
Future<void> _initializeControllerFuture; | |
@override | |
void initState() { | |
super.initState(); | |
// To display the current output from the camera, | |
// create a CameraController. | |
_controller = CameraController( | |
// Get a specific camera from the list of available cameras. | |
widget.camera, | |
// Define the resolution to use. | |
ResolutionPreset.medium, | |
); | |
// Next, initialize the controller. This returns a Future. | |
_initializeControllerFuture = _controller.initialize(); | |
} | |
@override | |
void dispose() { | |
// Dispose of the controller when the widget is disposed. | |
_controller.dispose(); | |
super.dispose(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
// Fill this out in the next steps. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment