MohamedAbd0 / widgets_to_image

Export your widget to image with flutter
https://pub.dev/packages/widgets_to_image
MIT License
21 stars 7 forks source link

not working with CameraPreview widget #1

Closed nasirdev74 closed 1 year ago

nasirdev74 commented 2 years ago

I'm using camera plugin to take picture. my camera preview widget is a small widget not full screen. but when I take picture, the camera controller takes picture from full screen camera. So I wanted to use this package to take picture only the part is visible in my screen. but it takes a black image only.

                         ClipRRect(
                            borderRadius: BorderRadius.circular(3),
                            child: Transform.scale(
                              scale: cameraController!.value.aspectRatio,
                              child: AspectRatio(
                                aspectRatio:cameraController!.value.aspectRatio,
                                child: Center(
                                  child: WidgetsToImage(
                                    controller: takeDocPictureController.widgetsToImageController,
                                    child: CameraPreview(cameraController!),
                                  ),
                                ),
                              ),
                            ),
                          )
MohamedAbd0 commented 1 year ago

hi, try putting the CameraPreview widget in Container with white color.

ClipRRect( borderRadius: BorderRadius.circular(3), child: Transform.scale( scale: cameraController!.value.aspectRatio, child: AspectRatio( aspectRatio:cameraController!.value.aspectRatio, child: Center( child: WidgetsToImage( controller: takeDocPictureController.widgetsToImageController, child: Container( color: Colors.white, child: CameraPreview(cameraController!), ) ), ), ), ), )

it will appered