Skip to content

Commit

Permalink
fix(windows): Fixed a bug when text fields were not accepting any inp…
Browse files Browse the repository at this point in the history
…ut after local authentication.

See flutter/flutter#122322.
  • Loading branch information
Skyost committed Jan 3, 2025
1 parent f23577a commit 152628e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/model/app_unlock/method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import 'package:open_authenticator/model/crypto.dart';
import 'package:open_authenticator/model/password_verification/methods/password_signature.dart';
import 'package:open_authenticator/model/password_verification/password_verification.dart';
import 'package:open_authenticator/model/totp/repository.dart';
import 'package:open_authenticator/utils/platform.dart';
import 'package:open_authenticator/utils/result.dart';
import 'package:open_authenticator/widgets/dialog/text_input_dialog.dart';
import 'package:window_manager/window_manager.dart';

/// Allows to unlock the app.
sealed class AppUnlockMethod {
Expand All @@ -34,6 +36,11 @@ class LocalAuthenticationAppUnlockMethod extends AppUnlockMethod {
if (!(await auth.isDeviceSupported())) {
return ResultError();
}
if (currentPlatform.isDesktop) {
await windowManager.ensureInitialized();
await windowManager.focus();
await windowManager.setAlwaysOnTop(true);
}
if (!context.mounted) {
return const ResultCancelled();
}
Expand Down Expand Up @@ -61,6 +68,14 @@ class LocalAuthenticationAppUnlockMethod extends AppUnlockMethod {
const WindowsAuthMessages(),
],
);
if (currentPlatform.isDesktop) {
if (currentPlatform == Platform.macOS || currentPlatform == Platform.windows) {
// See https://github.com/flutter/flutter/issues/122322.
await windowManager.blur();
await windowManager.focus();
}
await windowManager.setAlwaysOnTop(false);
}
return result ? const ResultSuccess() : const ResultCancelled();
}

Expand Down

0 comments on commit 152628e

Please sign in to comment.