Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception and modal barrier staying open when keyboard comes up while sheet closing animation. #140

Closed
SebastianEngel opened this issue May 24, 2024 · 7 comments
Labels
duplicate This issue or pull request already exists

Comments

@SebastianEngel
Copy link

SebastianEngel commented May 24, 2024

We have a sheet that covers half of the screen. When the user now double-taps on a textfield that is covered by the half-transparent barrier, A) the sheet closing animation starts and B) the soft keyboard comes up, both at the same time. This results in the barrier staying open (and the user unable to use the app) and the following exception in the logs:

#452    _InheritedProviderScopeElement.update (package:provider/src/inherited_provider.dart:523:11)
inherited_provider.dart:523
#453    Element.updateChild (package:flutter/src/widgets/framework.dart:3824:15)
framework.dart:3824
#454    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5505:16)
framework.dart:5505
#455    Element.rebuild (package:flutter/src/widgets/framework.dart:5196:7)
framework.dart:5196
#456    StatelessElement.update (package:flutter/src/widgets/framework.dart:5556:5)
framework.dart:5556
#457    Element.updateChild (package:flutter/src/widgets/framework.dart:3824:15)
framework.dart:3824
#458    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5505:16)
framework.dart:5505
#459    Element.rebuild (package:flutter/src/widgets/framework.dart:5196:7)
framework.dart:5196
#460    StatelessElement.update (package:flutter/src/widgets/framework.dart:5556:5)
framework.dart:5556
#461    Element.updateChild (package:flutter/src/widgets/framework.dart:3824:15)
framework.dart:3824
#462    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5505:16)
framework.dart:5505
#463    Element.rebuild (package:flutter/src/widgets/framework.dart:5196:7)
framework.dart:5196
#464    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2904:19)
framework.dart:2904
#465    WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:989:21)
binding.dart:989
#466    RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:448:5)
binding.dart:448
#467    SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1386:15)
binding.dart:1386
#468    SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1311:9)
binding.dart:1311
#469    SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:1169:5)
binding.dart:1169
#470    _invoke (dart:ui/hooks.dart:312:13)
hooks.dart:312
#471    PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:399:5)
platform_dispatcher.dart:399
#472    _drawFrame (dart:ui/hooks.dart:283:31)
hooks.dart:283
(elided 2 frames from class _AssertionError)

The ProxyAnimation notifying listeners was: kAlwaysCompleteAnimation➩ProxyAnimation
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════
Null check operator used on a null value
The relevant error-causing widget was:
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: _RenderSheetViewport#bc54c relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1972 pos 12: 'hasSize'
The relevant error-causing widget was:
════════════════════════════════════════════════════════════════════════════════

This happened on version 0.4.1 as well as the current 0.5.3.

Might be related to #14.

@fujidaiti
Copy link
Owner

Hi @SebastianEngel,

I have released a new version 0.6.0 which contains several improvements in modal sheets. Could you test it and confirm if the problem is fixed or still exists?

@SebastianEngel
Copy link
Author

Thanks @fujidaiti We tried it. Unfortunately the problem is still there.

════════ Exception caught by scheduler library ═════════════════════════════════
NavigationSheet: markAsDimensionsWillChange() was called more times than markAsDimensionsChanged() in a frame.
'package:smooth_sheets/src/foundation/sheet_extent.dart':
Failed assertion: line 247 pos 13: '_markAsDimensionsWillChangeCallCount == 0'
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by animation library ═════════════════════════════════
'package:smooth_sheets/src/navigation/navigation_sheet_extent.dart': Failed assertion: line 45 pos 12: '_localExtentScopeKeyRegistry.containsKey(route)': is not true.
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by animation library ═════════════════════════════════
'package:smooth_sheets/src/navigation/navigation_sheet_extent.dart': Failed assertion: line 45 pos 12: '_localExtentScopeKeyRegistry.containsKey(route)': is not true.
════════════════════════════════════════════════════════════════════════════════
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:smooth_sheets/src/navigation/navigation_sheet_extent.dart': Failed assertion: line 39 pos 12: '_localExtentScopeKeyRegistry.containsKey(route)': is not true.
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2      NavigationSheetExtent.disposeLocalExtentScopeKey (package:smooth_sheets/src/navigation/navigation_sheet_extent.dart:39:12)
#3      NavigationSheetRoute.dispose (package:smooth_sheets/src/navigation/navigation_route.dart:33:19)
#4      _RouteEntry.forcedDispose (package:flutter/src/widgets/navigator.dart:3165:11)
#5      _RouteEntry.dispose.<anonymous closure>.<anonymous closure> (package:flutter/src/widgets/navigator.dart:3220:13)
#6      _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#7      _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)

════════ Exception caught by rendering library ═════════════════════════════════
The sheet extent and the dimensions values must be finalized during the layout phase.
'package:smooth_sheets/src/foundation/sheet_viewport.dart':
Failed assertion: line 87 pos 7: '_extent.metrics.hasDimensions'

@SebastianEngel
Copy link
Author

SebastianEngel commented May 28, 2024

To summarize again:

We have a screen A with a textfield. On this screen the user can tap a button to open a sheet. The sheet then partly covers the screen.

The textfield in screen A is not directly covered by the sheet contents, but by the sheet's modal barrier. As its is half-transparent, we can see the textfield behind the barrier.

When the user now taps on the field, or anywhere on the background the sheet closes just fine.

But when the user double taps (two fast taps) on the field, the sheet closes but the barrier stays up, making the screen unusable. The log shows the posted exceptions. I suspect that it has something to do with the keyboard that pops up when the textfield receives focus, as then the dimensions change, probably while the sheet closing animation is still in progress.

@fujidaiti
Copy link
Owner

I tweaked the ai playlist generator example to have a text field on the background of the modal sheet, but couldn't reproduce the error. Can you post a code snippet related to your sheet? Then I could be of more help.

RocketSim_Recording_iPhone_15_6.1_2024-05-29_11.01.48.mp4

Here's the patch I applied to the ai playlist generator example.

diff --git forkSrcPrefix/cookbook/lib/showcase/ai_playlist_generator.dart forkDstPrefix/cookbook/lib/showcase/ai_playlist_generator.dart
index a0188d788081b784b43f3bca0f01de14b0848a10..99db164e6fb3401a80c59357e7435f11bf79db41 100644
--- forkSrcPrefix/cookbook/lib/showcase/ai_playlist_generator.dart
+++ forkDstPrefix/cookbook/lib/showcase/ai_playlist_generator.dart
@@ -132,10 +132,18 @@ class _Root extends StatelessWidget {
   @override
   Widget build(BuildContext context) {
     return Scaffold(
-        body: Center(
-      child: ElevatedButton(
-        onPressed: () => context.go('/intro'),
-        child: const Text('Generate Playlist'),
+        body: SafeArea(
+      child: Center(
+        child: Column(
+          children: [
+            TextFormField(),
+            const SizedBox(height: 60),
+            ElevatedButton(
+              onPressed: () => context.go('/intro'),
+              child: const Text('Generate Playlist'),
+            ),
+          ],
+        ),
       ),
     ));
   }
@@ -178,7 +186,7 @@ class _SheetShell extends StatelessWidget {
     return SafeArea(
       bottom: false,
       child: PopScope(
-        canPop: false,
+        canPop: true,
         onPopInvoked: (didPop) async {
           if (!didPop) {
             final shouldPop = await showCancelDialog() ?? false;

@fujidaiti fujidaiti added the need more information Lack of information to reproduce or determine if it is a bug or not label May 29, 2024
@fujidaiti
Copy link
Owner

Hi @SebastianEngel, someone posted an issue similar to this one with a screenshot (#152).
Can you check it out and confirm if it is the same problem you are experiencing or not?

@SebastianEngel
Copy link
Author

Yes, it's my colleague and the same issue 👍🏻

@fujidaiti
Copy link
Owner

Closing this as a duplicate of #152.

@fujidaiti fujidaiti added duplicate This issue or pull request already exists and removed need more information Lack of information to reproduce or determine if it is a bug or not labels Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants