camera_camera icon indicating copy to clipboard operation
camera_camera copied to clipboard

I would like to enable the front camera first

Open scherermathias opened this issue 4 years ago • 0 comments

I would like to enable the front camera first, but also be able to switch to the rear camera. How do I set it up this way?

late File selfie;
  bool camFront = true;

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: Column(
          children: [
            Flexible(
              flex: 3,
              child: Stack(
                children: [
                  CameraCamera(
                    onFile: (file) => showPreview(file),
                    cameraSide: camFront ? CameraSide.back : CameraSide.front,
                    enableZoom: false,
                    resolutionPreset: ResolutionPreset.medium,
                  ),
                  InkWell(
                    onTap: () {
                      setState(() {
                        camFront = !camFront;
                      });
                    },
                    child: Padding(
                      padding: const EdgeInsets.all(8.0),
                      child: Align(
                        alignment: Alignment.bottomRight,
                        child: CircleAvatar(
                          backgroundColor: greenIdent,
                          child: const Icon(
                            Icons.flip_camera_ios,
                            color: Colors.white,
                          ),
                        ),
                      ),
                    ),
                  )
                ],
              ),
            ),

scherermathias avatar Jul 23 '21 15:07 scherermathias