Skip to content

[documentation] [url_launcher] readme code sample is broken #71923

@iapicca

Description

@iapicca

Steps to Reproduce

  1. run flutter create issue
  2. replace the contents of main.dart with this code
  3. run flutter run -v

Logs

red screen

logs
[  +81 ms] Syncing files to device Pixel 3a...
[   +1 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[   +2 ms] <- recompile package:issue/main.dart f17a5964-e946-447d-97f9-843806625829
[        ] <- f17a5964-e946-447d-97f9-843806625829
[   +3 ms] I/flutter (21218): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
[        ] I/flutter (21218): The following assertion was thrown attaching to the render tree:
[        ] I/flutter (21218): No MediaQuery widget ancestor found.
[        ] I/flutter (21218): Scaffold widgets require a MediaQuery widget ancestor.
[        ] I/flutter (21218): The specific widget that could not find a MediaQuery ancestor was:
[        ] I/flutter (21218):   Scaffold
[        ] I/flutter (21218): The ownership chain for the affected widget is: "Scaffold ← [root]"
[        ] I/flutter (21218): No MediaQuery ancestor could be found starting from the context that was passed to MediaQuery.of().
[        ] I/flutter (21218): This can happen because you have not added a WidgetsApp, CupertinoApp, or MaterialApp widget (those
[        ] I/flutter (21218): widgets introduce a MediaQuery), or it can happen if the context you use comes from a widget above
[        ] I/flutter (21218): those widgets.
[        ] I/flutter (21218): 
[        ] I/flutter (21218): When the exception was thrown, this was the stack:
[        ] I/flutter (21218): #0      debugCheckHasMediaQuery.<anonymous closure> (package:flutter/src/widgets/debug.dart:218:7)
[        ] I/flutter (21218): #1      debugCheckHasMediaQuery (package:flutter/src/widgets/debug.dart:233:4)
[        ] I/flutter (21218): #2      MediaQuery.of (package:flutter/src/widgets/media_query.dart:820:12)
[        ] I/flutter (21218): #3      ScaffoldState.didChangeDependencies (package:flutter/src/material/scaffold.dart:2775:50)
[        ] I/flutter (21218): #4      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4842:11)
[        ] I/flutter (21218): #5      ComponentElement.mount (package:flutter/src/widgets/framework.dart:4658:5)
[        ] I/flutter (21218): #6      Element.inflateWidget (package:flutter/src/widgets/framework.dart:3624:14)
[        ] I/flutter (21218): #7      Element.updateChild (package:flutter/src/widgets/framework.dart:3389:18)
[        ] I/flutter (21218): #8      RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1208:16)
[        ] I/flutter (21218): #9      RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:1179:5)
[        ] I/flutter (21218): #10     RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:1121:18)
[        ] I/flutter (21218): #11     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2730:19)
[        ] I/flutter (21218): #12     RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:1120:13)
[        ] I/flutter (21218): #13     WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:960:7)
[        ] I/flutter (21218): #14     WidgetsBinding.scheduleAttachRootWidget.<anonymous closure> (package:flutter/src/widgets/binding.dart:941:7)
[        ] I/flutter (21218): (elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
[        ] I/flutter (21218): ════════════════════════════════════════════════════════════════════════════════════════════════════
[ +105 ms] Updating files.
[        ] DevFS: Sync finished
[   +1 ms] Syncing files to device Pixel 3a... (completed in 119ms)
[        ] Synced 0.0MB.
[        ] <- accept
[  +16 ms] Connected to _flutterView/0x77fe1640a0.
[   +1 ms] Flutter run key commands.
[   +1 ms] r Hot reload. 🔥🔥🔥
[   +1 ms] R Hot restart.
[        ] h Repeat this help message.
[        ] d Detach (terminate "flutter run" but leave application running).
[        ] c Clear the screen
[        ] q Quit (terminate the application on the device).
[        ] An Observatory debugger and profiler on Pixel 3a is available at: http://127.0.0.1:44743/7uH27cQa-ao=/
[        ] Running with unsound null safety
[        ] For more information see https://dart.dev/null-safety/unsound-null-safety
[+6086 ms] DevFS: Deleting filesystem on the device (file:///data/user/0/com.example.issue/code_cache/issueWXCJPO/issue/)
[  +32 ms] DevFS: Deleted filesystem on the device (file:///data/user/0/com.example.issue/code_cache/issueWXCJPO/issue/)
[ +309 ms] Failure in ext.flutter.exit: ext.flutter.exit: (-32000) Bad state: The client closed with pending request "ext.flutter.exit".

[  +15 ms] Service protocol connection closed.
[        ] Application finished.
[   +3 ms] executing: /home/francesco/Android/Sdk/platform-tools/adb -s 965AY0WP5C forward --list
[   +8 ms] Exit code 0 from: /home/francesco/Android/Sdk/platform-tools/adb -s 965AY0WP5C forward --list
[        ] 965AY0WP5C tcp:33501 tcp:39853
[   +1 ms] executing: /home/francesco/Android/Sdk/platform-tools/adb -s 965AY0WP5C forward --remove tcp:33501
[   +8 ms] executing: /home/francesco/Android/Sdk/platform-tools/adb -s 965AY0WP5C forward --list
[   +5 ms] Exit code 0 from: /home/francesco/Android/Sdk/platform-tools/adb -s 965AY0WP5C forward --list
[   +1 ms] "flutter run" took 37,757ms.
[ +255 ms] ensureAnalyticsSent: 252ms
[   +4 ms] Running shutdown hooks
[   +1 ms] Shutdown hook priority 4
[   +1 ms] Shutdown hooks complete
[        ] exiting with code 0

doctor
[✓] Flutter (Channel master, 1.25.0-5.0.pre.108, on Linux, locale en_US.UTF-8)
    • Flutter version 1.25.0-5.0.pre.108 at /home/francesco/snap/flutter/common/flutter
    • Framework revision 995aa138cd (13 hours ago), 2020-12-08 09:18:02 +0530
    • Engine revision b0d31ae166
    • Dart version 2.12.0 (build 2.12.0-125.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /home/francesco/Android/Sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /snap/android-studio/current/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
    • cmake version 3.10.2
    • ninja version 1.8.2
    • pkg-config version 0.29.1

[✓] Android Studio
    • Android Studio at /snap/android-studio/current/android-studio
    • 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
    • android-studio-dir = /snap/android-studio/current/android-studio
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] Connected device (3 available)
    • Pixel 3a (mobile) • 965AY0WP5C • android-arm64  • Android 11 (API 30)
    • Linux (desktop)   • linux      • linux-x64      • Linux
    • Chrome (web)      • chrome     • web-javascript • Google Chrome 87.0.4280.66

• No issues found!
pubspec
name: issue
description: A new Flutter project.
version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  url_launcher: ^5.7.10

flutter:
  uses-material-design: true

Proposed Solution

please consider this PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    d: examplesSample code and demosfound in release: 1.22Found to occur in 1.22has 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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions