@@ -1246,26 +1246,29 @@ class _VideoPlayerState extends State<VideoPlayer> {
12461246 WidgetsBinding .instance.addPostFrameCallback (_afterFrameLayout);
12471247 }
12481248
1249+ bool _isInvalid (double value) {
1250+ return value.isInfinite || value.isNaN;
1251+ }
1252+
12491253 void _afterFrameLayout (_) {
12501254 if (widget.controller.value.isInitialized) {
1251- final Rect currentRect = _getCurrentRect ();
1252- if (currentRect != Rect .zero && _playerRect != currentRect) {
1255+ final Rect rect = _getCurrentRect ();
1256+ if (rect != Rect .zero && _playerRect != rect) {
1257+ final double offsetLeft = rect.left - rect.left.floor ();
1258+ final double offsetTop = rect.top - rect.top.floor ();
1259+ final double offsetWidth = rect.width.ceil () - rect.width;
1260+ final double offsetHeight = rect.height.ceil () - rect.height;
1261+ final int left = _isInvalid (rect.left) ? 0 : rect.left.floor ();
1262+ final int top = _isInvalid (rect.top) ? 0 : rect.top.floor ();
1263+ final int width = _isInvalid (rect.width)
1264+ ? 1
1265+ : rect.width.ceil () + ((offsetLeft > offsetWidth) ? 1 : 0 );
1266+ final int height = _isInvalid (rect.height)
1267+ ? 1
1268+ : rect.height.ceil () + ((offsetTop > offsetHeight) ? 1 : 0 );
12531269 _videoPlayerPlatform.setDisplayGeometry (
1254- _playerId,
1255- (currentRect.left.isInfinite || currentRect.left.isNaN)
1256- ? 0
1257- : currentRect.left.toInt (),
1258- (currentRect.top.isInfinite || currentRect.top.isNaN)
1259- ? 0
1260- : currentRect.top.toInt (),
1261- (currentRect.width.isInfinite || currentRect.width.isNaN)
1262- ? 1
1263- : currentRect.width.toInt (),
1264- (currentRect.height.isInfinite || currentRect.height.isNaN)
1265- ? 1
1266- : currentRect.height.toInt (),
1267- );
1268- _playerRect = currentRect;
1270+ _playerId, left, top, width, height);
1271+ _playerRect = rect;
12691272 }
12701273 }
12711274 WidgetsBinding .instance.addPostFrameCallback (_afterFrameLayout);
0 commit comments