Giter VIP home page Giter VIP logo

Comments (3)

danagbemava-nc avatar danagbemava-nc commented on July 28, 2024

Reproducible using the code sample provided above.

logs
════════ Exception caught by widgets library ═══════════════════════════════════
The following assertion was thrown building RawGestureDetector(state: RawGestureDetectorState#f5ce9(gestures: [tap])):
OverlayPortalController.show() should not be called during build.
'package:flutter/src/widgets/overlay.dart':
Failed assertion: line 1814 pos 7: 'SchedulerBinding.instance.schedulerPhase != SchedulerPhase.persistentCallbacks'

Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.yml

The relevant error-causing widget was:
    GestureDetector GestureDetector:file:///Users/nexus/projects/nevercode/ipad/lib/main.dart:41:14

When the exception was thrown, this was the stack:
#2      _OverlayPortalState.show (package:flutter/src/widgets/overlay.dart:1814:7)
overlay.dart:1814
#3      OverlayPortalController.show (package:flutter/src/widgets/overlay.dart:1554:13)
overlay.dart:1554
#4      _MenuAnchorState._open (package:flutter/src/material/menu_anchor.dart:569:24)
menu_anchor.dart:569
#5      MenuController.open (package:flutter/src/material/menu_anchor.dart:680:14)
menu_anchor.dart:680
#6      _InnerMenuAnchorState.didUpdateWidget (package:ipad/main.dart:70:23)
main.dart:70
#7      StatefulElement.update (package:flutter/src/widgets/framework.dart:5789:55)
framework.dart:5789
#8      Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
framework.dart:3941
#9      SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6907:14)
framework.dart:6907
#10     Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
framework.dart:3941
#11     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6907:14)
framework.dart:6907
#12     Element.updateChild (package:flutter/src/widgets/framework.dart:3941:15)
framework.dart:3941
#13     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5642:16)
framework.dart:5642
#14     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:5780:11)
framework.dart:5780
flutter doctor -v
[!] Flutter (Channel stable, 3.22.2, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
    • Flutter version 3.22.2 on channel stable at /Users/nexus/dev/sdks/flutter
    ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (12 days ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/nexus/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode-15.3.0.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2

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

[✓] Android Studio (version 2024.1)
    • Android Studio at /Users/nexus/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 17.0.10+0-17.0.10b1087.21-11609105)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
    • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 77.2.2
    • Dart plugin version 232.10286

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

[✓] Connected device (5 available)
    • Nexus (mobile)                  • 00008020-001875E83A38002E • ios            • iOS 17.5.1 21F90
    • Dean’s iPad (mobile)            • 00008103-000825C811E3401E • ios            • iOS 17.5.1 21F90
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.4.1 23E224 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 126.0.6478.62

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
[✓] Flutter (Channel master, 3.23.0-13.0.pre.242, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
    • Flutter version 3.23.0-13.0.pre.242 on channel master at /Users/nexus/dev/sdks/flutters
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5187cab7bd (2 days ago), 2024-06-14 23:35:34 -0400
    • Engine revision 9779c273aa
    • Dart version 3.5.0 (build 3.5.0-266.0.dev)
    • DevTools version 2.36.0

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/nexus/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
    • Xcode at /Applications/Xcode-15.3.0.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.15.2

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

[✓] Android Studio (version 2024.1)
    • Android Studio at /Users/nexus/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 17.0.10+0-17.0.10b1087.21-11609105)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
    • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
    • Flutter plugin version 77.2.2
    • Dart plugin version 232.10286

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

[✓] Connected device (5 available)
    • Nexus (mobile)                  • 00008020-001875E83A38002E • ios            • iOS 17.5.1 21F90
    • Dean’s iPad (mobile)            • 00008103-000825C811E3401E • ios            • iOS 17.5.1 21F90
    • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.4.1 23E224 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 126.0.6478.62

[✓] Network resources
    • All expected network resources are available.

• No issues found!

from flutter.

TahaTesser avatar TahaTesser commented on July 28, 2024

@davidhicks980
This seems to be working as as expected according to the error message.

You can a build widget during build phase which is triggered by the secondary tap down in the sample

Try updating the open calling in a post frame callback, this is called after the widget finish building.

    SchedulerBinding.instance!.addPostFrameCallback((Duration timeStamp) {
      if (widget.position != oldWidget.position) {
        _menuController.open(position: widget.position);
      }
    });

from flutter.

davidhicks980 avatar davidhicks980 commented on July 28, 2024

Whoops sorry @TahaTesser -- I forgot to come back to this issue! Yeah, I wasn't sure whether it was an actual issue considering this is just the standard behavior of overlays. I did notice that the code for closing the menu contains a check for schedulerphase, so I wasn't sure if it was overlooked for opening or if this is expected behavior.

if (SchedulerBinding.instance.schedulerPhase != SchedulerPhase.persistentCallbacks) {

I also wasn't sure if there should be a "declarative" way of opening the menu. For example, web dialogs have an "open" parameter that will trigger their showing, rather than users having to call a function or otherwise having to wait for a frame. But if it's expected behavior, we can close this issue! Sorry for the trouble.

from flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.