0
controller
                        .capture(delay: Duration(milliseconds: 10))
                        .then((capturedImage) async {
                      final storageRef = FirebaseStorage.instance.ref();
                      final screenshotRef =
                          storageRef.child('/screenshot/1.jpg');
                      await screenshotRef.putData(capturedImage!);
                      final url = await screenshotRef.getDownloadURL();
                     
                      final bytes = readBytes(Uri.parse(url));
                      var file = [
                        File([bytes], "imagename.jpg", {"type": "image"})
                      ];
                      Map<String, dynamic> data = {
                        "title": "Internet Decides",
                        "text": "This is question",
                        "url": "https://internetdecides.com/test",
                        "files": file
                      };
                      await window.navigator.share(data);
                      print(url);
                      
                      
                    }).catchError((onError) {
                      print(onError);
                    });

I want to share screenshot with another app from flutter web, but when I try to fetch image from firebase then I have to run command "flutter run -d chrome --web-renderer html" to solve CORS error, but then it shows "Unsupported operation: toImage is not supported on the Web" this error.

When I try to run with "flutter run -d chrome --web-renderer canvaskit" then I got cors error, so how to solve this?

Harsh Bhalala
  • 173
  • 1
  • 2
  • 9

1 Answers1

1

With the html renderer for flutter web the RenderRepaintBoundary.toImage() function does not work as described here: https://github.com/flutter/flutter/issues/47721

To solve your problem you could try to use the canvaskit renderer again and solve the cors issue as described here: Flutter firebase storage CORS issue

Franz
  • 600
  • 1
  • 4
  • 12
  • You are right, html render is making problems on creating .toImage(). Once I made an output using canvaskit, everything started working – Rajesh Feb 20 '23 at 09:20