Skip to content

Commit

Permalink
await camera capture to prevent multiple button clicks resolves #118
Browse files Browse the repository at this point in the history
  • Loading branch information
russbiggs committed May 12, 2021
1 parent a73aede commit 4d1af91
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/ui/camera/camera_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class _CameraScreenState extends State<CameraScreen> {
String imgPath;
double _position;
String _pointId;
bool awaitingCapture = false;

Future initCamera(CameraDescription cameraDescription) async {
if (cameraController != null) {
Expand Down Expand Up @@ -118,9 +119,7 @@ class _CameraScreenState extends State<CameraScreen> {
color: Color.fromRGBO(0, 0, 0, 0.6),
),
backgroundColor: Color.fromRGBO(255, 255, 255, 0.2),
onPressed: () {
onCapture(context);
},
onPressed: awaitingCapture ? null : () => onCapture(context),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
Expand All @@ -132,7 +131,9 @@ class _CameraScreenState extends State<CameraScreen> {
final name = DateTime.now();
final path = "${p.path}/$name.png";
try {
awaitingCapture = true;
XFile img = await cameraController.takePicture();
awaitingCapture = false;
await img.saveTo(path);
Navigator.pushNamed(context, PreviewScreen.routeName,
arguments: PreviewScreenArguments(widget.surveyItemId, path,
Expand Down

0 comments on commit 4d1af91

Please sign in to comment.