Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align nullness with other SDKs #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

krocard
Copy link
Contributor

@krocard krocard commented Oct 6, 2023

Problem (PFL-69)

Methods that return nullable types on our native SDK were returning
placeholder values. This was not aligned with our other mobile
SDKs.

Changes

Return null instead. This also allows simplifying the glue layer.

Checklist

  • 🗒 CHANGELOG entry if applicable

Methods that return nullable types were returning
placeholder values. This was not aligned with our other mobile
SDKs.

This also allows simplifying the glue layer.

PFL-69
Copy link
Contributor

@testcenter testcenter left a comment

Choose a reason for hiding this comment

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

I like the changes 👍

await loadSourceConfig(Sources.sintel);
await callPlayer((player) async {
final subtitles = await player.availableSubtitles;
subtitleToSelect = subtitles.last.id;
subtitleToSelect = subtitles?.last.id;
Copy link
Contributor

Choose a reason for hiding this comment

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

do we also need the nullcheck on last? (subtitles?.last?.id)
or is this handled inside dart? 🤔

Copy link
Contributor Author

@krocard krocard Oct 16, 2023

Choose a reason for hiding this comment

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

Contrary to Kotlin, in a?.b.c, .c will only be called is a is not null. It would be equivalent to a?(.b.c) if such syntax was allowed.

Future<SubtitleTrack> get subtitle async =>
await _invokeObjectMethod<SubtitleTrack>(
Future<SubtitleTrack?> get subtitle async =>
_invokeObjectMethod<SubtitleTrack>(
Copy link
Contributor

Choose a reason for hiding this comment

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

why was the await removed?

Copy link
Contributor Author

@krocard krocard Oct 16, 2023

Choose a reason for hiding this comment

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

I don't believe it has any effect 🤔
What do you expect it to do?

Comment on lines +70 to +71
/// `null` if there are no active [Source].
Future<List<SubtitleTrack>?> get availableSubtitles;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was already aligned with the iOS and Android SDK. Both SDKs return an empty list. Why did you make the list nullable?

Comment on lines +74 to +75
/// `null` if there is no currently selected [SubtitleTrack].
Future<SubtitleTrack?> get subtitle;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This was aligned with iOS where we return the off-item in case there is no subtitle selected. I see that on Android this returns null in this case (which feels more right to me), so fine for me to align this with Android instead of iOS 👍 (no action required)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants