Open kaz080 opened 1 month ago
Hi,
You don't say anything about the fit
parameters of ApiVideoCameraPreview
. Have you tried to play with that?
Also, have you look for this error on stackoverflow?
Hi @ThibaultBee!
Yes, I tried fit
parameter for all types, but no luck.
Also I've look for this error on stackoverflow, e.g. https://stackoverflow.com/questions/52442724/boxconstraints-forces-an-infinite-width
As far as I tried, wrapping AspectRatio
or SizedBox
avoids this error.
(Also, this problem did not occur when I use version 1.0.7.)
Do you have the same issue on Android?
Have you tried Expanded
or Flexible
?
Yes.
Expanded
results another exception: RenderFlex children have non-zero flex but incoming height constraints are unbounded.
Flexible
also results RenderFlex children have non-zero flex but incoming height constraints are unbounded.
We don't have Android device now...
So the preview is trying to occupy the most space inside its container.
If one of the dimension of this container is infinite it will create such issue.
Putting the ApiVideoCameraPreview
is a SizedBox
that adds a constraint where the dimension is infinite will fix your issue (the height in your case).
SingleChildScrollView(
child: Column(
children: [
SizedBox(
height: 300,
child:
ApiVideoCameraPreview(controller: _controller, fit: BoxFit.fitWidth),
)
],
),
),
I also made a fix so it is not the case anymore. Could you test https://github.com/apivideo/api.video-flutter-live-stream/pull/58?
Version
v1.2.0
Which operating systems have you used?
Environment that reproduces the issue
Is it reproducible in the example application?
Yes
RTMP Server
none
Reproduction steps
I want the camera preview to remain full screen when the keyboard is opened, so I put it inside a SingleChildScrollView.
Replace example with the following to reproduce: https://github.com/apivideo/api.video-flutter-live-stream/blob/32b9f4c6e0913c1775b1f6467bd5625e3dace469/example/lib/main.dart#L113
Expected result
The width is fixed and it would be good if the height is also adjusted automatically.
Actual result
Additional context
ApiVideoCameraPreview()
needs to be wrapped withAspectRatio(aspectRatio: 9 / 16)
. However, when the device is in landscape orientation, the aspectRatio becomes incorrect.videoSize
andorientation
insideApiVideoCameraPreview
, could we put theAspectRatio
inside and build with the appropriate aspectRatio?Relevant logs output
No response