Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[video_player] bugfix caption still showing when text is empty #3374

Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bfccbd6
Merge pull request #1 from flutter/master
vanlooverenkoen Dec 27, 2020
a6e3702
#72999 Fixed the caption widget where it should not show the widget i…
vanlooverenkoen Dec 27, 2020
6c08796
Updated the docs
vanlooverenkoen Dec 27, 2020
322b096
Fixed formatting
vanlooverenkoen Dec 27, 2020
f5b9d66
Merge branch 'master' into bugfix/#72999-caption-still-showing
Salakar Jan 8, 2021
38c390e
Update pubspec version
Salakar Jan 8, 2021
b9dee24
Apply suggestions from code review
Salakar Jan 8, 2021
d7a084e
Apply suggestions from code review
Salakar Jan 8, 2021
127fb1f
Update packages/video_player/video_player/lib/video_player.dart
Salakar Jan 8, 2021
9c76835
Update video_player.dart
Salakar Jan 8, 2021
a23c003
Merge pull request #2 from flutter/master
vanlooverenkoen Jan 15, 2021
f5f26fa
Merge pull request #3 from flutter/master
vanlooverenkoen Jan 18, 2021
360a0af
Merge pull request #4 from flutter/master
vanlooverenkoen Jan 23, 2021
2baf0a7
Merge branch 'master' into bugfix/#72999-caption-still-showing
vanlooverenkoen Jan 23, 2021
c101198
Updated version
vanlooverenkoen Jan 23, 2021
246a042
Merge pull request #5 from flutter/master
vanlooverenkoen Mar 11, 2021
a9d6fc4
Merge branch 'master' into bugfix/#72999-caption-still-showing
vanlooverenkoen Mar 11, 2021
7570933
Merge pull request #6 from flutter/master
vanlooverenkoen Jul 24, 2021
bbdc044
Merge branch 'master' into bugfix/#72999-caption-still-showing
vanlooverenkoen Jul 24, 2021
60ca485
Added an extra test for empty caption text
vanlooverenkoen Jul 24, 2021
45cbf7d
Merge branch 'master' into bugfix/#72999-caption-still-showing
stuartmorgan Sep 14, 2021
5709a81
Merge branch 'master' into bugfix/#72999-caption-still-showing
stuartmorgan Sep 15, 2021
62ae245
Merge branch 'master' into bugfix/#72999-caption-still-showing
stuartmorgan Sep 15, 2021
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.0.0-nullsafety.8

* Fixed empty caption text still showing the caption widget.

## 2.0.0-nullsafety.7

* Update the example app: remove the deprecated `RaisedButton` and `FlatButton` widgets.
Expand Down
14 changes: 8 additions & 6 deletions packages/video_player/video_player/lib/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -890,11 +890,12 @@ class ClosedCaption extends StatelessWidget {
/// Creates a a new closed caption, designed to be used with
/// [VideoPlayerValue.caption].
///
/// If [text] is null, nothing will be displayed.
/// If [text] is null or empty, nothing will be displayed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally text should be non-nullable with a default to '' so that we don't have two ways of expressing the same thing, but unfortunately that would be a breaking change at this point.

const ClosedCaption({Key? key, this.text, this.textStyle}) : super(key: key);

/// The text that will be shown in the closed caption, or null if no caption
/// should be shown.
/// If the text is empty the caption will not be shown as well
Salakar marked this conversation as resolved.
Show resolved Hide resolved
Salakar marked this conversation as resolved.
Show resolved Hide resolved
final String? text;

/// Specifies how the text in the closed caption should look.
Expand All @@ -905,16 +906,17 @@ class ClosedCaption extends StatelessWidget {

@override
Widget build(BuildContext context) {
final captionText = text;
if (captionText == null || captionText.isEmpty) {
return SizedBox.shrink();
}

Salakar marked this conversation as resolved.
Show resolved Hide resolved
final TextStyle effectiveTextStyle = textStyle ??
DefaultTextStyle.of(context).style.copyWith(
fontSize: 36.0,
color: Colors.white,
);

if (text == null) {
return SizedBox.shrink();
}

return Align(
alignment: Alignment.bottomCenter,
child: Padding(
Expand All @@ -926,7 +928,7 @@ class ClosedCaption extends StatelessWidget {
),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 2.0),
child: Text(text!, style: effectiveTextStyle),
child: Text(captionText, style: effectiveTextStyle),
Salakar marked this conversation as resolved.
Show resolved Hide resolved
),
),
),
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 @@ -4,7 +4,7 @@ description: Flutter plugin for displaying inline video with other Flutter
# 0.10.y+z is compatible with 1.0.0, if you land a breaking change bump
# the version to 2.0.0.
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
version: 2.0.0-nullsafety.7
version: 2.0.0-nullsafety.8
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player

flutter:
Expand Down