This file contains hidden or 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
| Widget cameraOptionsWidget() { | |
| return Padding( | |
| padding: const EdgeInsets.all(5.0), | |
| child: Row( | |
| mainAxisAlignment: MainAxisAlignment.start, | |
| children: <Widget>[ | |
| showCamera ? cameraTogglesRowWidget() : Container(), | |
| ], | |
| ), | |
| ); |
This file contains hidden or 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
| void onTakePictureButtonPressed() { | |
| takePicture().then((String filePath) { | |
| if (mounted) { | |
| setState(() { | |
| showCamera = false; | |
| imagePath = filePath; | |
| }); | |
| } | |
| }); | |
| } |
This file contains hidden or 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
| Widget captureControlRowWidget() { | |
| return Row( | |
| mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |
| mainAxisSize: MainAxisSize.max, | |
| children: <Widget>[ | |
| IconButton( | |
| icon: const Icon(Icons.camera_alt), | |
| color: Colors.blue, | |
| onPressed: controller != null && controller.value.isInitialized | |
| ? onTakePictureButtonPressed |
This file contains hidden or 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
| Widget editCaptureControlRowWidget() { | |
| return Padding( | |
| padding: const EdgeInsets.only(top: 5), | |
| child: Align( | |
| alignment: Alignment.topCenter, | |
| child: IconButton( | |
| icon: const Icon(Icons.camera_alt), | |
| color: Colors.blue, | |
| onPressed: () => setState(() { | |
| showCamera = true; |
This file contains hidden or 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
| Widget imagePreviewWidget() { | |
| return Container( | |
| child: Padding( | |
| padding: const EdgeInsets.only(top: 10), | |
| child: Align( | |
| alignment: Alignment.topCenter, | |
| child: imagePath == null | |
| ? null | |
| : SizedBox( | |
| child: Image.file(File(imagePath)), |
This file contains hidden or 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
| Widget cameraPreviewWidget() { | |
| if (!isReady || !controller.value.isInitialized) { | |
| return Container(); | |
| } | |
| return AspectRatio( | |
| aspectRatio: controller.value.aspectRatio, | |
| child: CameraPreview(controller)); | |
| } |
This file contains hidden or 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
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| key: scaffoldKey, | |
| body: Center( | |
| child: SingleChildScrollView( | |
| padding: const EdgeInsets.all(8.0), | |
| child: Column( | |
| children: <Widget>[ | |
| Center( | |
| child: showCamera |
This file contains hidden or 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
| @override | |
| void initState() { | |
| super.initState(); | |
| setupCameras(); | |
| } | |
| Future<void> setupCameras() async { | |
| try { | |
| cameras = await availableCameras(); | |
| controller = new CameraController(cameras[0], ResolutionPreset.medium); |
This file contains hidden or 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
| class CameraState extends State<CameraWidget> { | |
| final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); | |
| List<CameraDescription> cameras; | |
| CameraController controller; | |
| bool isReady = false; | |
| bool showCamera = true; | |
| String imagePath; | |
| // Inputs | |
| TextEditingController nameController = TextEditingController(); | |
| TextEditingController countryController = TextEditingController(); |
This file contains hidden or 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
| final widgetOptions = [ | |
| new BeerListPage(), | |
| new CameraWidget(), | |
| Text('Favourites'), | |
| ]; |