content: import 'dart:io';
  
  import 'package:camera/camera.dart';
  import 'package:flutter/material.dart';
  
  class CameraPage extends StatefulWidget {
    final CameraDescription camera;
  
    const CameraPage({
      super.key,
      required this.camera,
    });
  
    @override
    TakePictureScreenState createState() => TakePictureScreenState();
  }
  
  class TakePictureScreenState extends State<CameraPage> {
    late CameraController _controller;
    late Future<void> _initializeControllerFuture;
  
    @override
    void initState() {
      super.initState();
      _controller = CameraController(
        widget.camera,
        ResolutionPreset.high,
      );
      _initializeControllerFuture = _controller.initialize();
    }
  
    @override
    void dispose() {
      _controller.dispose();
      super.dispose();
    }
  
    @override
    Widget build(BuildContext context) {
      final size = MediaQuery.of(context).size;
      return Scaffold(
        appBar: AppBar(title: const Text('Take a picture')),
        body: FutureBuilder<void>(
          future: _initializeControllerFuture,
          builder: (context, snapshot) {
            if (snapshot.connectionState == ConnectionState.done) {
              return //CameraPreview(_controller);
                  SizedBox(
                      width: size.width,
                      height: size.height,
                      child: FittedBox(
                        fit: BoxFit.cover,
                        child: SizedBox(
                            width: 100, // the actual width is not important here
                            child: CameraPreview(_controller)),
                      ));
            } else {
              return const Center(child: CircularProgressIndicator());
            }
          },
        ),
        floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
        floatingActionButton: FloatingActionButton(
          child: const Icon(Icons.camera_alt),
          onPressed: () async {
            try {
              await _initializeControllerFuture;
              _controller.setFlashMode(FlashMode.off);
              _controller.setExposureMode(ExposureMode.auto);
              final image = await _controller.takePicture();
              // If the picture was taken, display it on a new screen.
              // Navigator.push(
              //   context,
              //   MaterialPageRoute(
              //     builder: (context) => DisplayPictureScreen(imagePath: image.path),
              //   ),
              // );
              Navigator.pop(context, image.path);
            } catch (e) {
              print(e);
            }
          },
        ),
      );
    }
  }
  
  class DisplayPictureScreen extends StatelessWidget {
    final String imagePath;
  
    const DisplayPictureScreen({super.key, required this.imagePath});
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(title: const Text('Display the Picture')),
        body: Expanded(child: Image.file(File(imagePath))),
      );
    }
  }
  