gallery icon indicating copy to clipboard operation
gallery copied to clipboard

Gallery shrine demo WillPopScope in ExpandingBottomSheet doesn't work!

Open songtao542 opened this issue 5 years ago • 7 comments

songtao542 avatar May 30 '19 11:05 songtao542

I'd like to track this down. Can you provide a description of what's going wrong: how you're interacting with the demo, what you're seeing, what you expect to see, etc?

HansMuller avatar May 30 '19 16:05 HansMuller

Step:

  1. Open Gallery -> click "Studies" -> click "Shrine" -> click "NEXT" ;
  2. Add some product into the cart;
  3. Click the cart (at bottom) to expand the cart;
  4. Click "Back" key(the "back" at Android Navigation bar)

result: the app back to the Studies page

expect: the app just collapse the cart, not leave the product page.

songtao542 avatar May 31 '19 01:05 songtao542

Thanks for explaining the problem. You're right: in this case the system back button should do the same thing as the app's back button (the down-arrow in the upper left-hand corner).

HansMuller avatar May 31 '19 15:05 HansMuller

I took a look at this, and it seems the problem might be coming from the fact that the Shrine app is nested inside the Gallery app. Both the gallery and Shrine have their own Navigators. As a result, WillPopScope in Shrine is inside an inner navigator and is ignored.

I got the cart to close properly again by wrapping the MaterialApp in Shrine with a WillPopScope and adding a GlobalKey for the ExpandingBottomSheetState (see here). Does this look like a reasonable solution, or is there a way to do this without wrapping the MaterialApp with a WillPopScope?

michdud avatar Nov 15 '19 21:11 michdud

Is the problem that the WillPopScope widget's callback unconditionally pops the outermost navigator? Maybe _onWillPop() in expanding_bottom_sheet.dart needs to be changed?

HansMuller avatar Nov 15 '19 21:11 HansMuller

As far as I can tell, the callback isn't called at all. I tried moving the WillPopScope widget up the tree, and the only time the callback was called was when it wrapped the Shrine MaterialApp.

michdud avatar Nov 15 '19 21:11 michdud

Still the case in the latest version of gallery b5e9c40 built with latest master 1.23.0-8.0.pre.164.

flutter doctor -v
[√] Flutter (Channel master, 1.23.0-8.0.pre.164, on Microsoft Windows [Version 10.0.19041.508], locale en-US)
    • Flutter version 1.23.0-8.0.pre.164 at C:\Development\flutter_master
    • Framework revision b3bd9e6924 (3 hours ago), 2020-10-05 19:52:03 -0700
    • Engine revision 284ef2217d
    • Dart version 2.11.0 (build 2.11.0-186.0.dev)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
    • Android SDK at C:\Users\marku\AppData\Local\Android\sdk
    • Platform android-30, build-tools 30.0.1
    • Java binary at: C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\193.6626763\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.6.5)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
    • Visual Studio Community 2019 version 16.6.30320.27
    • Windows 10 SDK version 10.0.18362.0

[√] Android Studio (version 4.0)
    • Android Studio at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\193.6626763
    • Flutter plugin version 47.1.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] Connected device (6 available)
    • SM G950F (mobile)           • ce12171c51cc001c03 • android-arm64  • Android 9 (API 28)
    • sdk gphone x86 arm (mobile) • emulator-5554      • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)           • windows            • windows-x64    • Microsoft Windows [Version 10.0.19041.508]
    • Web Server (web)            • web-server         • web-javascript • Flutter Tools
    • Chrome (web)                • chrome             • web-javascript • Google Chrome 85.0.4183.121
    • Edge (web)                  • edge               • web-javascript • Microsoft Edge 85.0.564.68

• No issues found!

markusaksli-nc avatar Sep 24 '20 08:09 markusaksli-nc