Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- key: _scaffoldKey,
- body: Stack(
- children: <Widget>[
- FutureBuilder<void>(
- future: _initializeControllerFuture,
- builder: (context, snapshot) {
- if (snapshot.connectionState == ConnectionState.done) {
- return Stack(
- alignment: FractionalOffset.center,
- children: <Widget>[
- new Positioned.fill(
- child: _getCameraPreview(context),
- ),
- new Positioned.fill(
- child: new Opacity(
- opacity: 0.7,
- child: Image.asset(
- _layoutPath,
- scale: 5,
- fit: BoxFit.none,
- alignment: Alignment(0.2, 0.1),
- )),
- ),
- ],
- );
- } else {
- return Center(child: CircularProgressIndicator());
- }
- },
- ),
- Align(
- alignment: Alignment.bottomCenter,
- child: BottomAppBar(
- color: Color.fromARGB(0, 0, 0, 0),
- child: _getBottomAppBarRow(context),
- ),
- ),
- ],
- ),
- );
- }
- _getCameraPreview(BuildContext context) {
- final size = MediaQuery.of(context).size;
- final deviceRatio = size.width / size.height;
- return Transform.scale(
- scale: _controller.value.aspectRatio / deviceRatio,
- child: Center(
- child: AspectRatio(
- aspectRatio: _controller.value.aspectRatio,
- child: CameraPreview(_controller),
- ),
- ),
- );
- }
- final shutterButton = Material(
- elevation: 5.0,
- borderRadius: BorderRadius.circular(30.0),
- color: AppColors.white,
- child: FloatingActionButton(
- child: Icon(
- Icons.camera,
- color: AppColors.white,
- size: 24,
- ),
- onPressed: () async {
- try {
- await _initializeControllerFuture;
- final path = join(
- (await getTemporaryDirectory()).path,
- '${DateTime.now()}.png',
- );
- await _controller.takePicture(path);
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => DisplayPictureScreen(imagePath: path),
- ),
- );
- _controller.dispose();
- } catch (e) {
- print(e);
- }
- },
- ),
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement