Closed omar-hanafy closed 3 years ago
I have fixed this by initializing the PanelController out of the build widget and declare it as final
ex: final PanelController _pc = PanelController();
Another cause of this error can be usage of the PanelController outside of the widget in which you attach the PanelController to the Panel. This can be fixed by adding: _pc.isAttached ? [ your code with _pc ] : [ some code not utilizing _pc ( e.g. Container() ) ]
This issue is still relevant in case of hot reload. Hot restart seems to resolve this, yet it's annoying to hot restart each time you change some kind of code in your codebase.
A quick solve is also to move "final PanelController _pc = PanelController();" outside of the class.
@akshathjain I have the same problem. I tried to use a button outside the panel to handle closing the panel and got this error. Has anyone got a solution for this problem?
if you have a StateFulWidget , the best way is in this Example :
_panelController.isAttached ? DoSthWhileTrue : DoSthWhileFasle
[x] - You cannot use the panelController.panelPosition
without check isAttached result!
Describe the bug in my app I am trying to open/close the panel manually by pressing the header of the panel or any button in the body() but I found this error"
Log Message The following assertion was thrown while handling a gesture: PanelController must be attached to a SlidingUpPanel 'package:sliding_up_panel/src/panel.dart': Failed assertion: line 629 pos 12: 'isAttached'
When the exception was thrown, this was the stack:
2 PanelController.open (package:sliding_up_panel/src/panel.dart:629:12)
3 MyHome._body. (package:gym_bar_sales/ui/views/Add/sliding_up_panel_widget.dart:31:21)
4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
5 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:1111:38)
6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
... Handler: "onTap" Recognizer: TapGestureRecognizer#4971a debugOwner: GestureDetector state: possible won arena finalPosition: Offset(656.5, 105.5) finalLocalPosition: Offset(60.5, 19.5) button: 1 sent tap down ═══════════════════════════════════════════════════════
Expected behavior the panel open or close when calling _pc.open() or .close()
Smartphone
Sample
main.dart