LinusU / LinusU/flutter_web_auth

[macOS] [version 0.4.3]: unexpectedly found nil while unwrapping an Optional value

Open
#155 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Dart
Stars
213
Forks
261
PR merge metrics
No merged PRs in 30d

Description

Getting this error when trying to perform a redirect to my auth:

`flutter_web_auth/FlutterWebAuthPlugin.swift:38: Fatal error: Unexpectedly found nil while unwrapping an Optional value`

Tried looking at the code in question, but unfamiliar with Swift, seems to be that ``keyWindow`` is null? Is there any setup step for macOS that is needed before using this library?

```swift
guard let provider = NSApplication.shared.keyWindow!.contentViewController as? FlutterViewController else {
result(FlutterError(code: "FAILED", message: "Failed to aquire root FlutterViewController" , details: nil))
return
}
```

flutter doctor output:
```
~/$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.10.1, on macOS 13.3.1 22E772610a darwin-arm64, locale en-PT)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.1.3)
[✓] VS Code (version 1.78.1)
[✓] Connected device (2 available)
[✓] Network resources

• No issues found!
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in flutter_web_auth/FlutterWebAuthPlugin.swift at line 38 and review the macOS authentication redirect path around the keyWindow access. Reproduce the redirect with the reported Flutter 3.10.1 and macOS setup, then add or update a focused test or validation so the authentication flow no longer crashes when the expected window or controller is unavailable.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, macos, swift
Domain
desktop-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.