Skip to content

Commit

Permalink
Fix method channel casts. Version 0.1.0-nullsafety.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanheise committed Feb 1, 2021
1 parent ce76ad3 commit 685bed5
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.0-nullsafety.3

* Fix casts on method channel invocations.

## 0.1.0-nullsafety.2

* Merge features and bug fixes from 0.0.10 and 0.0.11.
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.0-nullsafety.2"
version: "0.1.0-nullsafety.3"
boolean_selector:
dependency: transitive
description:
Expand Down
7 changes: 3 additions & 4 deletions lib/src/android.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ class AndroidAudioManager {

Future<bool> requestAudioFocus(AndroidAudioFocusRequest focusRequest) async {
_onAudioFocusChanged = focusRequest.onAudioFocusChanged;
return await (_channel.invokeMethod<bool>(
'requestAudioFocus', [focusRequest.toJson()]) as FutureOr<bool>);
return (await (_channel
.invokeMethod<bool>('requestAudioFocus', [focusRequest.toJson()])))!;
}

Future<bool> abandonAudioFocus() async {
return await (_channel.invokeMethod<bool>('abandonAudioFocus')
as FutureOr<bool>);
return (await (_channel.invokeMethod<bool>('abandonAudioFocus')))!;
}

void close() {
Expand Down
37 changes: 16 additions & 21 deletions lib/src/darwin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ class AVAudioSession {
_mediaServicesWereResetSubject.stream;

Future<AVAudioSessionCategory> get category async {
final index =
await (_channel.invokeMethod<int>('getCategory') as FutureOr<int>);
final index = (await (_channel.invokeMethod<int>('getCategory')))!;
return AVAudioSessionCategory.values[index];
}

Expand All @@ -95,14 +94,12 @@ class AVAudioSession {
.toList();

Future<AVAudioSessionCategoryOptions> get categoryOptions async {
final value = await (_channel.invokeMethod<int>('getCategoryOptions')
as FutureOr<int>);
final value = (await (_channel.invokeMethod<int>('getCategoryOptions')))!;
return AVAudioSessionCategoryOptions(value);
}

Future<AVAudioSessionMode> get mode async {
final index =
await (_channel.invokeMethod<int>('getMode') as FutureOr<int>);
final index = (await (_channel.invokeMethod<int>('getMode')))!;
return AVAudioSessionMode.values[index];
}

Expand All @@ -125,29 +122,27 @@ class AVAudioSession {
}

Future<bool> setActive(bool active,
{AVAudioSessionSetActiveOptions? avOptions}) =>
_channel.invokeMethod<bool>('setActive', [active, avOptions?.value])
as Future<bool>;
{AVAudioSessionSetActiveOptions? avOptions}) async =>
(await _channel
.invokeMethod<bool>('setActive', [active, avOptions?.value]))!;

Future<AVAudioSessionRecordPermission> get recordPermission async {
final index = await (_channel.invokeMethod<int>('getRecordPermission')
as FutureOr<int>);
final index = (await (_channel.invokeMethod<int>('getRecordPermission')))!;
return AVAudioSessionRecordPermission.values[index];
}

Future<bool> requestRecordPermission() =>
_channel.invokeMethod<bool>('requestRecordPermission') as Future<bool>;
Future<bool> requestRecordPermission() async =>
(await _channel.invokeMethod<bool>('requestRecordPermission'))!;

Future<bool> get isOtherAudioPlaying =>
_channel.invokeMethod<bool>('isOtherAudioPlaying') as Future<bool>;
Future<bool> get isOtherAudioPlaying async =>
(await _channel.invokeMethod<bool>('isOtherAudioPlaying'))!;

Future<bool> get secondaryAudioShouldBeSilencedHint =>
_channel.invokeMethod<bool>('getSecondaryAudioShouldBeSilencedHint')
as Future<bool>;
Future<bool> get secondaryAudioShouldBeSilencedHint async => (await _channel
.invokeMethod<bool>('getSecondaryAudioShouldBeSilencedHint'))!;

Future<bool> get allowHapticsAndSystemSoundsDuringRecording => _channel
.invokeMethod<bool>('getAllowHapticsAndSystemSoundsDuringRecording')
as Future<bool>;
Future<bool> get allowHapticsAndSystemSoundsDuringRecording async =>
(await _channel.invokeMethod<bool>(
'getAllowHapticsAndSystemSoundsDuringRecording'))!;

Future<void> setAllowHapticsAndSystemSoundsDuringRecording(bool allow) =>
_channel.invokeMethod(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: audio_session
description: Sets the iOS audio session category and Android audio attributes for your app, and manages your app's audio focus, mixing and ducking behaviour.
version: 0.1.0-nullsafety.2
version: 0.1.0-nullsafety.3
homepage: https://github.com/ryanheise/audio_session

environment:
Expand Down

0 comments on commit 685bed5

Please sign in to comment.