Skip to content

[macos][url_launcher] MissingPluginException is thrown when url_launcher_macos is not added to dependencies #98097

@domesticmouse

Description

@domesticmouse

I'm working my way through https://codelabs.developers.google.com/codelabs/flutter-github-client?hl=en#3 with Flutter 2.10

$ flutter doctor -v
[✓] Flutter (Channel stable, 2.10.0, on macOS 12.2 21D49 darwin-x64, locale en)
    • Flutter version 2.10.0 at /Users/brettmorgan/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5f105a6ca7 (7 days ago), 2022-02-01 14:15:42 -0800
    • Engine revision 776efd2034
    • Dart version 2.16.0
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/brettmorgan/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.64.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.34.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 12.2 21D49 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 98.0.4758.80

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

When I run the code as is, it fails when I attempt to open a URL in a browser on macOS.

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method canLaunch on channel plugins.flutter.io/url_launcher)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:175:7)
<asynchronous suspension>
#1      canLaunch (package:url_launcher/url_launcher.dart:131:10)
<asynchronous suspension>
#2      _GithubLoginState._redirect (package:github_client/src/github_login.dart:103:9)
<asynchronous suspension>
#3      _GithubLoginState._getOAuth2Client (package:github_client/src/github_login.dart:94:5)
<asynchronous suspension>
#4      _GithubLoginState.build.<anonymous closure> (package:github_client/src/github_login.dart:66:43)
<asynchronous suspension>

However, if I directly add the endorsed url_launcher_macos package, it works.

$ flutter pub add url_launcher_macos

Can someone explain what is going wrong here? Do I need to update the codelab?

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: desktopRunning on desktopfound in release: 2.10Found to occur in 2.10found in release: 2.11Found to occur in 2.11has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: url_launcherPlugin to launch external applicationspackageflutter/packages repository. See also p: labels.platform-macBuilding on or for macOS specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions