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

Commit c702665

Browse files
committed
[video_player] updated nullability in pigeon files
1 parent d9a9307 commit c702665

File tree

17 files changed

+274
-242
lines changed

17 files changed

+274
-242
lines changed

packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java

Lines changed: 89 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,29 @@
2222
/** Generated class from Pigeon. */
2323
@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"})
2424
public class Messages {
25+
2526
/** Generated class from Pigeon that represents data sent in messages. */
2627
public static class TextureMessage {
27-
private @Nullable Long textureId;
28+
private @NonNull Long textureId;
2829

29-
public @Nullable Long getTextureId() {
30+
public @NonNull Long getTextureId() {
3031
return textureId;
3132
}
3233

33-
public void setTextureId(@Nullable Long setterArg) {
34+
public void setTextureId(@NonNull Long setterArg) {
35+
if (setterArg == null) {
36+
throw new IllegalStateException("Nonnull field \"textureId\" is null.");
37+
}
3438
this.textureId = setterArg;
3539
}
3640

41+
/** Constructor is private to enforce null safety; use Builder. */
42+
private TextureMessage() {}
43+
3744
public static class Builder {
3845
private @Nullable Long textureId;
3946

40-
public @NonNull Builder setTextureId(@Nullable Long setterArg) {
47+
public @NonNull Builder setTextureId(@NonNull Long setterArg) {
4148
this.textureId = setterArg;
4249
return this;
4350
}
@@ -69,37 +76,46 @@ Map<String, Object> toMap() {
6976

7077
/** Generated class from Pigeon that represents data sent in messages. */
7178
public static class LoopingMessage {
72-
private @Nullable Long textureId;
79+
private @NonNull Long textureId;
7380

74-
public @Nullable Long getTextureId() {
81+
public @NonNull Long getTextureId() {
7582
return textureId;
7683
}
7784

78-
public void setTextureId(@Nullable Long setterArg) {
85+
public void setTextureId(@NonNull Long setterArg) {
86+
if (setterArg == null) {
87+
throw new IllegalStateException("Nonnull field \"textureId\" is null.");
88+
}
7989
this.textureId = setterArg;
8090
}
8191

82-
private @Nullable Boolean isLooping;
92+
private @NonNull Boolean isLooping;
8393

84-
public @Nullable Boolean getIsLooping() {
94+
public @NonNull Boolean getIsLooping() {
8595
return isLooping;
8696
}
8797

88-
public void setIsLooping(@Nullable Boolean setterArg) {
98+
public void setIsLooping(@NonNull Boolean setterArg) {
99+
if (setterArg == null) {
100+
throw new IllegalStateException("Nonnull field \"isLooping\" is null.");
101+
}
89102
this.isLooping = setterArg;
90103
}
91104

105+
/** Constructor is private to enforce null safety; use Builder. */
106+
private LoopingMessage() {}
107+
92108
public static class Builder {
93109
private @Nullable Long textureId;
94110

95-
public @NonNull Builder setTextureId(@Nullable Long setterArg) {
111+
public @NonNull Builder setTextureId(@NonNull Long setterArg) {
96112
this.textureId = setterArg;
97113
return this;
98114
}
99115

100116
private @Nullable Boolean isLooping;
101117

102-
public @NonNull Builder setIsLooping(@Nullable Boolean setterArg) {
118+
public @NonNull Builder setIsLooping(@NonNull Boolean setterArg) {
103119
this.isLooping = setterArg;
104120
return this;
105121
}
@@ -135,37 +151,46 @@ Map<String, Object> toMap() {
135151

136152
/** Generated class from Pigeon that represents data sent in messages. */
137153
public static class VolumeMessage {
138-
private @Nullable Long textureId;
154+
private @NonNull Long textureId;
139155

140-
public @Nullable Long getTextureId() {
156+
public @NonNull Long getTextureId() {
141157
return textureId;
142158
}
143159

144-
public void setTextureId(@Nullable Long setterArg) {
160+
public void setTextureId(@NonNull Long setterArg) {
161+
if (setterArg == null) {
162+
throw new IllegalStateException("Nonnull field \"textureId\" is null.");
163+
}
145164
this.textureId = setterArg;
146165
}
147166

148-
private @Nullable Double volume;
167+
private @NonNull Double volume;
149168

150-
public @Nullable Double getVolume() {
169+
public @NonNull Double getVolume() {
151170
return volume;
152171
}
153172

154-
public void setVolume(@Nullable Double setterArg) {
173+
public void setVolume(@NonNull Double setterArg) {
174+
if (setterArg == null) {
175+
throw new IllegalStateException("Nonnull field \"volume\" is null.");
176+
}
155177
this.volume = setterArg;
156178
}
157179

180+
/** Constructor is private to enforce null safety; use Builder. */
181+
private VolumeMessage() {}
182+
158183
public static class Builder {
159184
private @Nullable Long textureId;
160185

161-
public @NonNull Builder setTextureId(@Nullable Long setterArg) {
186+
public @NonNull Builder setTextureId(@NonNull Long setterArg) {
162187
this.textureId = setterArg;
163188
return this;
164189
}
165190

166191
private @Nullable Double volume;
167192

168-
public @NonNull Builder setVolume(@Nullable Double setterArg) {
193+
public @NonNull Builder setVolume(@NonNull Double setterArg) {
169194
this.volume = setterArg;
170195
return this;
171196
}
@@ -201,37 +226,46 @@ Map<String, Object> toMap() {
201226

202227
/** Generated class from Pigeon that represents data sent in messages. */
203228
public static class PlaybackSpeedMessage {
204-
private @Nullable Long textureId;
229+
private @NonNull Long textureId;
205230

206-
public @Nullable Long getTextureId() {
231+
public @NonNull Long getTextureId() {
207232
return textureId;
208233
}
209234

210-
public void setTextureId(@Nullable Long setterArg) {
235+
public void setTextureId(@NonNull Long setterArg) {
236+
if (setterArg == null) {
237+
throw new IllegalStateException("Nonnull field \"textureId\" is null.");
238+
}
211239
this.textureId = setterArg;
212240
}
213241

214-
private @Nullable Double speed;
242+
private @NonNull Double speed;
215243

216-
public @Nullable Double getSpeed() {
244+
public @NonNull Double getSpeed() {
217245
return speed;
218246
}
219247

220-
public void setSpeed(@Nullable Double setterArg) {
248+
public void setSpeed(@NonNull Double setterArg) {
249+
if (setterArg == null) {
250+
throw new IllegalStateException("Nonnull field \"speed\" is null.");
251+
}
221252
this.speed = setterArg;
222253
}
223254

255+
/** Constructor is private to enforce null safety; use Builder. */
256+
private PlaybackSpeedMessage() {}
257+
224258
public static class Builder {
225259
private @Nullable Long textureId;
226260

227-
public @NonNull Builder setTextureId(@Nullable Long setterArg) {
261+
public @NonNull Builder setTextureId(@NonNull Long setterArg) {
228262
this.textureId = setterArg;
229263
return this;
230264
}
231265

232266
private @Nullable Double speed;
233267

234-
public @NonNull Builder setSpeed(@Nullable Double setterArg) {
268+
public @NonNull Builder setSpeed(@NonNull Double setterArg) {
235269
this.speed = setterArg;
236270
return this;
237271
}
@@ -267,37 +301,46 @@ Map<String, Object> toMap() {
267301

268302
/** Generated class from Pigeon that represents data sent in messages. */
269303
public static class PositionMessage {
270-
private @Nullable Long textureId;
304+
private @NonNull Long textureId;
271305

272-
public @Nullable Long getTextureId() {
306+
public @NonNull Long getTextureId() {
273307
return textureId;
274308
}
275309

276-
public void setTextureId(@Nullable Long setterArg) {
310+
public void setTextureId(@NonNull Long setterArg) {
311+
if (setterArg == null) {
312+
throw new IllegalStateException("Nonnull field \"textureId\" is null.");
313+
}
277314
this.textureId = setterArg;
278315
}
279316

280-
private @Nullable Long position;
317+
private @NonNull Long position;
281318

282-
public @Nullable Long getPosition() {
319+
public @NonNull Long getPosition() {
283320
return position;
284321
}
285322

286-
public void setPosition(@Nullable Long setterArg) {
323+
public void setPosition(@NonNull Long setterArg) {
324+
if (setterArg == null) {
325+
throw new IllegalStateException("Nonnull field \"position\" is null.");
326+
}
287327
this.position = setterArg;
288328
}
289329

330+
/** Constructor is private to enforce null safety; use Builder. */
331+
private PositionMessage() {}
332+
290333
public static class Builder {
291334
private @Nullable Long textureId;
292335

293-
public @NonNull Builder setTextureId(@Nullable Long setterArg) {
336+
public @NonNull Builder setTextureId(@NonNull Long setterArg) {
294337
this.textureId = setterArg;
295338
return this;
296339
}
297340

298341
private @Nullable Long position;
299342

300-
public @NonNull Builder setPosition(@Nullable Long setterArg) {
343+
public @NonNull Builder setPosition(@NonNull Long setterArg) {
301344
this.position = setterArg;
302345
return this;
303346
}
@@ -462,20 +505,26 @@ Map<String, Object> toMap() {
462505

463506
/** Generated class from Pigeon that represents data sent in messages. */
464507
public static class MixWithOthersMessage {
465-
private @Nullable Boolean mixWithOthers;
508+
private @NonNull Boolean mixWithOthers;
466509

467-
public @Nullable Boolean getMixWithOthers() {
510+
public @NonNull Boolean getMixWithOthers() {
468511
return mixWithOthers;
469512
}
470513

471-
public void setMixWithOthers(@Nullable Boolean setterArg) {
514+
public void setMixWithOthers(@NonNull Boolean setterArg) {
515+
if (setterArg == null) {
516+
throw new IllegalStateException("Nonnull field \"mixWithOthers\" is null.");
517+
}
472518
this.mixWithOthers = setterArg;
473519
}
474520

521+
/** Constructor is private to enforce null safety; use Builder. */
522+
private MixWithOthersMessage() {}
523+
475524
public static class Builder {
476525
private @Nullable Boolean mixWithOthers;
477526

478-
public @NonNull Builder setMixWithOthers(@Nullable Boolean setterArg) {
527+
public @NonNull Builder setMixWithOthers(@NonNull Boolean setterArg) {
479528
this.mixWithOthers = setterArg;
480529
return this;
481530
}

packages/video_player/video_player_android/android/src/main/java/io/flutter/plugins/videoplayer/VideoPlayerPlugin.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ public TextureMessage create(CreateMessage arg) {
156156
}
157157
videoPlayers.put(handle.id(), player);
158158

159-
TextureMessage result = new TextureMessage();
160-
result.setTextureId(handle.id());
159+
TextureMessage result = new TextureMessage.Builder().setTextureId(handle.id()).build();
161160
return result;
162161
}
163162

@@ -189,8 +188,11 @@ public void play(TextureMessage arg) {
189188

190189
public PositionMessage position(TextureMessage arg) {
191190
VideoPlayer player = videoPlayers.get(arg.getTextureId());
192-
PositionMessage result = new PositionMessage();
193-
result.setPosition(player.getPosition());
191+
PositionMessage result =
192+
new PositionMessage.Builder()
193+
.setPosition(player.getPosition())
194+
.setTextureId(arg.getTextureId())
195+
.build();
194196
player.sendBufferingUpdate();
195197
return result;
196198
}

packages/video_player/video_player_android/lib/src/android_video_player.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class AndroidVideoPlayer extends VideoPlayerPlatform {
105105
Future<Duration> getPosition(int textureId) async {
106106
final PositionMessage response =
107107
await _api.position(TextureMessage(textureId: textureId));
108-
return Duration(milliseconds: response.position!);
108+
return Duration(milliseconds: response.position);
109109
}
110110

111111
@override

0 commit comments

Comments
 (0)