Skip to content

[video_player] Fix layout issue caused by Transform.rotate not affecting space calculation. #8685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/video_player/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.9.5

* Fixes layout issue caused by `Transform.rotate` not affecting space calculation.

## 2.9.4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a new version bump; the previous one was lost in a merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue has been fixed. A new version bump has been added.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


* Reduces the position update interval from 500ms to 100ms.
Expand Down
20 changes: 12 additions & 8 deletions packages/video_player/video_player/lib/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import 'dart:async';
import 'dart:io';
import 'dart:math' as math;

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -882,17 +881,22 @@ class _VideoPlayerState extends State<VideoPlayer> {
}

class _VideoPlayerWithRotation extends StatelessWidget {
const _VideoPlayerWithRotation({required this.rotation, required this.child});
const _VideoPlayerWithRotation({required this.rotation, required this.child})
: assert(rotation % 90 == 0, 'Rotation must be a multiple of 90');

final int rotation;
final Widget child;

@override
Widget build(BuildContext context) => rotation == 0
? child
: Transform.rotate(
angle: rotation * math.pi / 180,
child: child,
);
Widget build(BuildContext context) {
if (rotation == 0) {
return child;
}
return RotatedBox(
quarterTurns: rotation ~/ 90,
child: child,
);
}
}

/// Used to configure the [VideoProgressIndicator] widget's colors for how it
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for displaying inline video with other Flutter
widgets on Android, iOS, and web.
repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
version: 2.9.4
version: 2.9.5

environment:
sdk: ^3.4.0
Expand Down
22 changes: 6 additions & 16 deletions packages/video_player/video_player/test/video_player_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import 'dart:async';
import 'dart:io';
import 'dart:math' as math;
import 'dart:typed_data';

import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -178,28 +176,20 @@ void main() {
addTearDown(controller.dispose);
controller.textureId = 1;
await tester.pumpWidget(VideoPlayer(controller));
final Transform actualRotationCorrection =
find.byType(Transform).evaluate().single.widget as Transform;
final Float64List actualRotationCorrectionStorage =
actualRotationCorrection.transform.storage;
final Float64List expectedMatrixStorage =
Matrix4.rotationZ(math.pi).storage;
expect(actualRotationCorrectionStorage.length,
equals(expectedMatrixStorage.length));
for (int i = 0; i < actualRotationCorrectionStorage.length; i++) {
expect(actualRotationCorrectionStorage[i],
moreOrLessEquals(expectedMatrixStorage[i]));
}
final RotatedBox actualRotationCorrection =
find.byType(RotatedBox).evaluate().single.widget as RotatedBox;
final int actualQuarterTurns = actualRotationCorrection.quarterTurns;
expect(actualQuarterTurns, equals(2));
});

testWidgets('no transform when rotationCorrection is zero',
testWidgets('no RotatedBox when rotationCorrection is zero',
(WidgetTester tester) async {
final FakeController controller =
FakeController.value(const VideoPlayerValue(duration: Duration.zero));
addTearDown(controller.dispose);
controller.textureId = 1;
await tester.pumpWidget(VideoPlayer(controller));
expect(find.byType(Transform), findsNothing);
expect(find.byType(RotatedBox), findsNothing);
});

group('ClosedCaption widget', () {
Expand Down