Skip to content

Commit 3665c9f

Browse files
author
Emmanuel Garcia
authored
[video_player] Add toString() to Caption (flutter#3233)
1 parent 3a4e307 commit 3665c9f

File tree

5 files changed

+43
-2
lines changed

5 files changed

+43
-2
lines changed

packages/video_player/video_player/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.11.1+4
2+
3+
* Add `toString()` to `Caption`.
4+
15
## 0.11.1+3
26

37
* Android: Upgrade ExoPlayer to 2.12.1.

packages/video_player/video_player/lib/src/closed_caption_file.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,13 @@ class Caption {
4545
/// The actual text that should appear on screen to be read between [start]
4646
/// and [end].
4747
final String text;
48+
49+
@override
50+
String toString() {
51+
return '$runtimeType('
52+
'number: $number, '
53+
'start: $start, '
54+
'end: $end, '
55+
'text: $text)';
56+
}
4857
}

packages/video_player/video_player/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Flutter plugin for displaying inline video with other Flutter
44
# 0.10.y+z is compatible with 1.0.0, if you land a breaking change bump
55
# the version to 2.0.0.
66
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
7-
version: 0.11.1+3
7+
version: 0.11.1+4
88
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player
99

1010
flutter:
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2020 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter_test/flutter_test.dart';
6+
import 'package:video_player/src/closed_caption_file.dart';
7+
8+
void main() {
9+
group('ClosedCaptionFile', () {
10+
test('toString()', () {
11+
final Caption caption = const Caption(
12+
number: 1,
13+
start: Duration(seconds: 1),
14+
end: Duration(seconds: 2),
15+
text: 'caption',
16+
);
17+
18+
expect(
19+
caption.toString(),
20+
'Caption('
21+
'number: 1, '
22+
'start: 0:00:01.000000, '
23+
'end: 0:00:02.000000, '
24+
'text: caption'
25+
')');
26+
});
27+
});
28+
}

packages/video_player/video_player/test/video_player_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ void main() {
566566
'VideoPlayerValue(duration: 0:00:05.000000, '
567567
'size: Size(400.0, 300.0), '
568568
'position: 0:00:01.000000, '
569-
'caption: Instance of \'Caption\', '
569+
'caption: Caption(number: null, start: null, end: null, text: foo), '
570570
'buffered: [DurationRange(start: 0:00:00.000000, end: 0:00:04.000000)], '
571571
'isPlaying: true, '
572572
'isLooping: true, '

0 commit comments

Comments
 (0)