Skip to content

Commit 8cecf09

Browse files
committed
feat(lib): update video class member nullability
1 parent 596c3bc commit 8cecf09

File tree

3 files changed

+69
-60
lines changed

3 files changed

+69
-60
lines changed

lib/src/types/video.dart

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ class Video {
4141
final String videoId;
4242

4343
/// When a video was created, presented in ISO-8601 format.
44-
final DateTime? createdAt;
44+
final DateTime createdAt;
4545

4646
/// The title of the video content.
47-
final String? title;
47+
final String title;
4848

4949
/// The description for the video content.
50-
final String? description;
50+
final String description;
5151

5252
/// The date and time the API created the video. Date and time are provided using ISO-8601 UTC format.
53-
final String? publishedAt;
53+
final String publishedAt;
5454

5555
/// The date and time the video was updated. Date and time are provided using ISO-8601 UTC format.
56-
final DateTime? updatedAt;
56+
final DateTime updatedAt;
5757

5858
/// The date and time the video was discarded.
5959
final DateTime? discardedAt;
@@ -62,7 +62,7 @@ class Video {
6262
final DateTime? deletesAt;
6363

6464
/// Returns `true` for videos you discarded.
65-
final bool? discarded;
65+
final bool discarded;
6666

6767
/// Returns the language of a video in [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag) format.
6868
@_JsonLocaleConverter()
@@ -72,50 +72,49 @@ class Video {
7272
final LanguageOrigin? languageOrigin;
7373

7474
/// One array of tags (each tag is a string) in order to categorize a video. Tags may include spaces.
75-
final List<String>? tags;
75+
final List<String> tags;
7676

7777
/// Metadata you can use to categorise and filter videos. Metadata is a list of dictionaries, where each dictionary represents a key value pair for categorising a video. [Dynamic Metadata](https://api.video/blog/endpoints/dynamic-metadata) allows you to define a key that allows any value pair.
78-
final List<Metadata>? metadata;
78+
final List<Metadata> metadata;
7979

8080
/// The source information about the video.
81-
final VideoSource? source;
81+
final VideoSource source;
8282

8383
/// The details about the video object that you can use to work with the video object.
84-
final VideoAssets? assets;
84+
final VideoAssets assets;
8585

8686
/// The id of the player that will be applied on the video.
8787
final String? playerId;
8888

8989
/// Defines if the content is publicly reachable or if a unique token is needed for each play session. Default is true. Tutorials on [private videos](https://api.video/blog/endpoints/private-videos).
90-
@JsonKey(name: '_public')
91-
final bool? public;
90+
final bool public;
9291

9392
/// Defines if video is panoramic.
94-
final bool? panoramic;
93+
final bool panoramic;
9594

9695
/// This lets you know whether mp4 is supported. If enabled, an mp4 URL will be provided in the response for the video.
97-
final bool? mp4Support;
96+
final bool mp4Support;
9897

9998
/// Creates a [Video].
10099
const Video(this.videoId,
101-
{this.createdAt,
102-
this.title,
103-
this.description,
104-
this.publishedAt,
105-
this.updatedAt,
100+
{required this.createdAt,
101+
required this.title,
102+
required this.description,
103+
required this.publishedAt,
104+
required this.updatedAt,
106105
this.discardedAt,
107106
this.deletesAt,
108-
this.discarded,
107+
required this.discarded,
109108
this.language,
110109
this.languageOrigin,
111-
this.tags,
112-
this.metadata,
113-
this.source,
114-
this.assets,
110+
required this.tags,
111+
required this.metadata,
112+
required this.source,
113+
required this.assets,
115114
this.playerId,
116-
this.public,
117-
this.panoramic,
118-
this.mp4Support});
115+
required this.public,
116+
required this.panoramic,
117+
required this.mp4Support});
119118

120119
/// Creates a [Video] from a [json] map.
121120
factory Video.fromJson(Map<String, dynamic> json) => _$VideoFromJson(json);

lib/src/types/video.g.dart

Lines changed: 17 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/video_uploader_mobile_test.dart

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@ void main() {
1212
const MethodChannel channel = const MethodChannel('video.api.uploader');
1313
ApiVideoUploaderPlatform.instance = ApiVideoMobileUploaderPlugin();
1414

15+
Video _createDummyVideo(String videoId) {
16+
return Video(videoId,
17+
createdAt: DateTime.now(),
18+
title: "Title",
19+
description: "Description",
20+
publishedAt: DateTime.now(),
21+
updatedAt: DateTime.now(),
22+
discarded: false,
23+
tags: [],
24+
metadata: [],
25+
source: VideoSource(),
26+
assets: VideoAssets(),
27+
public: false,
28+
panoramic: false,
29+
mp4Support: false,
30+
);
31+
}
32+
1533
test('setEnvironment', () async {
1634
final environment = Environment.sandbox;
1735
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
@@ -57,7 +75,7 @@ void main() {
5775
expect(null, isNot(methodCall.arguments["uploadId"]));
5876
expect(methodCall.arguments["videoId"], videoId);
5977
expect(methodCall.arguments["filePath"], filePath);
60-
return jsonEncode(Video(videoId).toJson());
78+
return jsonEncode(_createDummyVideo(videoId).toJson());
6179
} else {
6280
fail("Method not expected: ${methodCall.method}");
6381
}
@@ -78,7 +96,7 @@ void main() {
7896
expect(null, isNot(methodCall.arguments["uploadId"]));
7997
expect(methodCall.arguments["token"], token);
8098
expect(methodCall.arguments["filePath"], filePath);
81-
return jsonEncode(Video(videoId).toJson());
99+
return jsonEncode(_createDummyVideo(videoId).toJson());
82100
} else {
83101
fail("Method not expected: ${methodCall.method}");
84102
}
@@ -96,7 +114,7 @@ void main() {
96114
return null;
97115
} else if (methodCall.method == "uploadWithUploadToken") {
98116
expect(null, isNot(methodCall.arguments["uploadId"]));
99-
return jsonEncode(Video(videoId).toJson());
117+
return jsonEncode(_createDummyVideo(videoId).toJson());
100118
} else {
101119
fail("Method not expected: ${methodCall.method}");
102120
}
@@ -131,7 +149,7 @@ void main() {
131149
expect(null, isNot(methodCall.arguments["uploadId"]));
132150
expect(methodCall.arguments["sessionId"], sessionId);
133151
expect(methodCall.arguments["filePath"], filePath);
134-
return jsonEncode(Video(videoId).toJson());
152+
return jsonEncode(_createDummyVideo(videoId).toJson());
135153
} else {
136154
fail("Method not expected: ${methodCall.method}");
137155
}
@@ -148,7 +166,7 @@ void main() {
148166
expect(null, isNot(methodCall.arguments["uploadId"]));
149167
expect(methodCall.arguments["sessionId"], sessionId);
150168
expect(methodCall.arguments["filePath"], filePath);
151-
return jsonEncode(Video(videoId).toJson());
169+
return jsonEncode(_createDummyVideo(videoId).toJson());
152170
} else {
153171
fail("Method not expected: ${methodCall.method}");
154172
}
@@ -184,7 +202,7 @@ void main() {
184202
expect(null, isNot(methodCall.arguments["uploadId"]));
185203
expect(methodCall.arguments["sessionId"], sessionId);
186204
expect(methodCall.arguments["filePath"], filePath);
187-
return jsonEncode(Video(videoId).toJson());
205+
return jsonEncode(_createDummyVideo(videoId).toJson());
188206
} else {
189207
fail("Method not expected: ${methodCall.method}");
190208
}
@@ -201,11 +219,12 @@ void main() {
201219
expect(null, isNot(methodCall.arguments["uploadId"]));
202220
expect(methodCall.arguments["sessionId"], sessionId);
203221
expect(methodCall.arguments["filePath"], filePath);
204-
return jsonEncode(Video(videoId).toJson());
222+
return jsonEncode(_createDummyVideo(videoId).toJson());
205223
} else {
206224
fail("Method not expected: ${methodCall.method}");
207225
}
208226
});
209227
expect((await session.uploadLastPart(filePath)).videoId, videoId);
210228
});
229+
211230
}

0 commit comments

Comments
 (0)