diff --git a/packages/video_player/video_player/CHANGELOG.md b/packages/video_player/video_player/CHANGELOG.md index bbbdd0c5b85..e36eed3374a 100644 --- a/packages/video_player/video_player/CHANGELOG.md +++ b/packages/video_player/video_player/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.9.5 + +* Fixes layout issue caused by `Transform.rotate` not affecting space calculation. + ## 2.9.4 * Reduces the position update interval from 500ms to 100ms. diff --git a/packages/video_player/video_player/lib/video_player.dart b/packages/video_player/video_player/lib/video_player.dart index 0f56ae0146d..12b30c2a146 100644 --- a/packages/video_player/video_player/lib/video_player.dart +++ b/packages/video_player/video_player/lib/video_player.dart @@ -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'; @@ -882,17 +881,22 @@ class _VideoPlayerState extends State { } 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 diff --git a/packages/video_player/video_player/pubspec.yaml b/packages/video_player/video_player/pubspec.yaml index a12cf336024..0f80d59e6a9 100644 --- a/packages/video_player/video_player/pubspec.yaml +++ b/packages/video_player/video_player/pubspec.yaml @@ -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 diff --git a/packages/video_player/video_player/test/video_player_test.dart b/packages/video_player/video_player/test/video_player_test.dart index 279490ad94b..a7b0888faa6 100644 --- a/packages/video_player/video_player/test/video_player_test.dart +++ b/packages/video_player/video_player/test/video_player_test.dart @@ -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'; @@ -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', () {