Baseflow / screenrecorder

Flutter package which can be used to record flutter widgets
https://pub.dev/packages/screen_recorder
MIT License
64 stars 30 forks source link

Error Trying To Record #16

Closed rlee1990 closed 1 year ago

rlee1990 commented 2 years ago

When I try to record I receive this error Exception: _containerKey.currentContext is null. Thus we can't create a screenshot

ueman commented 2 years ago

Which version of Flutter are you using?

rlee1990 commented 1 year ago

Which version of Flutter are you using?

@ueman I am using flutter 3.3.8

rlee1990 commented 1 year ago

@ueman any ideas on what it could be?

ueman commented 1 year ago

No, unfortunately not. Can you post a minimal example to reproduce the error?

rlee1990 commented 1 year ago

No, unfortunately not. Can you post a minimal example to reproduce the error?

@ueman I am using it like this inside a stack

 ScreenRecorder(
                        background: Colors.black,
                        width: MediaQuery.of(context).size.width,
                        height: MediaQuery.of(context).size.height,
                        controller: screenRecorderController!,
                        child: Stack(
                          alignment: Alignment.center,
                          children: [
                            Center(
                              child: Image.file(
                                newFile!,
                                fit: BoxFit.cover,
                              ),
                            ),
                            for (int i = 0; i < addedWidgets.length; i++)
                              addedWidgets[i],
                          ],
                        ),
                      ),
rlee1990 commented 1 year ago

I made a fork of the package and made this change

Future<ui.Image> capture() async {
    final renderObject = _containerKey.currentContext!.findRenderObject()
        as RenderRepaintBoundary;

    return await renderObject.toImage(pixelRatio: pixelRatio);
  }
rlee1990 commented 1 year ago

I no longer get the error but also everything is null.

rlee1990 commented 1 year ago

@ueman if you check this example that I made on how mine is setup it also returns null. Ill keep playing around to find the root cause. Example

rlee1990 commented 1 year ago

Also, why does version 0.1.0 require a nonstable version of flutter?

ueman commented 1 year ago

Also, why does version 0.1.0 require a nonstable version of flutter?

It makes use of new APIs which make taking the recording easier.

rlee1990 commented 1 year ago

Also, why does version 0.1.0 require a nonstable version of flutter?

It makes use of new APIs which make taking the recording easier.

Let me try to upgrade flutter to this and see if this fix the issue. Its odd I use the example with the changes I made to the package and it somewhat works just very delayed

rlee1990 commented 1 year ago

@ueman so I tried using the lastest Flutter master branch but I cannot as other packages(alot) are not supporting it that I rely on. So trying with version 0.0.3 of this package but the data is always null when returned.