Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/src/floating.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ class Floating {
///
/// Note: this will not make any effect on Android SDK older than 26.
Future<PiPStatus> enable(EnableArguments arguments) async {
lastEnableArguments = arguments;
final (aspectRatio, sourceRectHint, autoEnable) = switch (arguments) {
ImmediatePiP(:final aspectRatio, :final sourceRectHint) => (
aspectRatio,
Expand All @@ -138,7 +137,12 @@ class Floating {
// Cancel any previous settings in case it would interfere with the
// current ones, e.g. current one is ImmediatePiP but OnLeavePiP
// was called before.
await cancelOnLeavePiP();
try {
await cancelOnLeavePiP();
} finally {
// Ensure lastEnableArguments is always set, even if cancelOnLeavePiP throws.
lastEnableArguments = arguments;
}
final bool? enabledSuccessfully = await _channel.invokeMethod(
'enablePip',
{
Expand Down