Skip to content

Instantly share code, notes, and snippets.

@BoshiLee
Created December 12, 2019 08:20
Show Gist options
  • Save BoshiLee/6e5c5aa0bb645e695629a5c5c1883710 to your computer and use it in GitHub Desktop.
Save BoshiLee/6e5c5aa0bb645e695629a5c5c1883710 to your computer and use it in GitHub Desktop.
// You must wait until the controller is initialized before displaying the
// camera preview. Use a FutureBuilder to display a loading spinner until the
// controller has finished initializing.
FutureBuilder<void>(
future: _initializeControllerFuture,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
// If the Future is complete, display the preview.
return CameraPreview(_controller);
} else {
// Otherwise, display a loading indicator.
return Center(child: CircularProgressIndicator());
}
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment