akshathjain / sliding_up_panel

A draggable Flutter widget that makes implementing a SlidingUpPanel much easier!
https://pub.dartlang.org/packages/sliding_up_panel
Other
1.38k stars 381 forks source link

Can't use PanelController.open(); when panelBuilder is used and isDraggable are true. #130

Open alvarogabrielgomez opened 4 years ago

alvarogabrielgomez commented 4 years ago

Describe the bug I trying to use a buttom to extend the panel using PanelController.open() function in a FlatButtom but does not work when im using the panelBuilder on it ... When i use a body instead of a panelBuilder it works...

If the isDraggable is setted as false and i using the panelBuilder it works too.

(Sorry for my bad english)

To Reproduce Steps to reproduce the behavior:

  1. Create a Widget SlidingUpPanel and wrap it in a StatefulWidget.
  2. Pass a panelBuilder "panelBuilder: (ScrollController sc) => _scrollingList(sc),"
  3. Pass a PanelController.
  4. Set isDraggable as True
  5. Set defaultPanelState as PanelState.CLOSED
  6. In the Widget that returns _scrollingList() wrap a GridView.builder or ListView.builder on a Stack
  7. Create in front of ListView.builder or GridView.builder a Container with a FlatButton inside
  8. On the onPressed() function ; if (widget.panelController.isPanelClosed) { setState(() { print("Open Panel"); widget.panelController.open(); }); } else { setState(() { print("Close Panel"); widget.panelController.close(); }); } 20 Put your StatefullWidget with the SlidingUpPanel inside on your body of the Scaffold
  9. Compile
  10. Try using the Flatbutton that is suposed to close and open the panel.

Expected behavior Im expect to open and close the panel when i tap the flatbutton but only close it

Smartphone (please complete the following information):

return SlidingUpPanel( collapsed: widget.panelCollapsed, isDraggable: widget.menuIsDraggable, panelBuilder: (ScrollController sc) => _scrollingList(sc), backdropEnabled: false, onPanelClosed: widget.onPanelClosed, onPanelOpened: widget.onPanelOpened, onPanelSlide: widget.onPanelSlide, snapPoint: widget.snapPoint, boxShadow: <BoxShadow>[ BoxShadow( color: Colors.black38.withOpacity(0.2), blurRadius: 1.0, // has the effect of softening the shadow spreadRadius: 0.2, // has the effect of extending the shadow offset: Offset( 0.0, // horizontal, move right 10 -1.3, // vertical, move down 10 ), ), ], defaultPanelState: widget.defaultPanelState, controller: widget.panelController, margin: MediaQuery.of(context).size.width > 800 ? EdgeInsets.only(left: 23, right: 23) : null, minHeight: widget.minHeight != null ? widget.minHeight : 160, maxHeight: widget.maxHeight != null ? widget.maxHeight : MediaQuery.of(context).size.height - 255, padding: EdgeInsets.only(left: 10, right: 10, top: 0), borderRadius: BorderRadius.only( topLeft: Radius.circular(28), topRight: Radius.circular(28)), body: widget.body, ); }

Widget _scrollingList(ScrollController sc) { final Orientation orientation = MediaQuery.of(context).orientation; return MediaQuery.removePadding( context: context, removeTop: true, child: Stack( children: <Widget>[ GridView.builder( shrinkWrap: true, physics: BouncingScrollPhysics(), controller: sc, itemCount: 50, padding: EdgeInsets.only(top: 50), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( childAspectRatio: (orientation == Orientation.portrait) ? (28 / 36) : (32 / 25), crossAxisSpacing: 10, mainAxisSpacing: 18, crossAxisCount: (orientation == Orientation.portrait) ? 3 : 4, ), itemBuilder: (BuildContext context, int i) { return Container( child: ItemMenuTid( onTap: () { Navigator.push( context, MaterialPageRoute(builder: (context) => TestPage()), ); }, ), ); }, ), Container( width: double.infinity, alignment: Alignment.topCenter, child: Container( height: 35, child: FlatButton( onPressed: () { if (widget.panelController.isPanelClosed) { setState(() { widget.panelController.animatePanelToPosition(1); }); } else { setState(() { widget.panelController.close(); }); } }, child: Container( decoration: BoxDecoration( color: Colors.black26, borderRadius: BorderRadius.circular(10), ), height: 4, width: 30, ), ), ), ), ], ), ); } UPDATES: Im trying to debug a panel, so im made this. image

The panel keep in the Animating state when are open or closed... I dont know why

image

Probably is for this what the buttom does not work