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

BUG : panelBuilder bad behaviour with listview #142

Open QuentinSc opened 4 years ago

QuentinSc commented 4 years ago

(hope my english is clear)

Describe the bug Became crazy after spend my evening on this. It seems there is a bug when using SlidingUp panel with list view. It's not working with some parameter from the sliding up widget. In some case the listview keep the focus while the panel is closed.

To Reproduce Use the code sample for panelBuilder. Enable backdropTapClosesPanel Scroll up to open the panel. Scroll the list. Tap on the backdrop to close the panel The listview became scrollable in the panel closed and it's became complicated to reopen the panel.

Expected behavior Reopen the panel on scroll up. Option to make the scrollcontroller jump to begin when the panel is closed.

Smartphone (please complete the following information):

Sample main.dart Please provide a sample main.dart that reproduces this issue. The code provided here should be able to be run on its own without any external dependencies.

  Widget build(BuildContext context) {
    //print(token.access);
    return Container(
        child: SlidingUpPanel(
      backdropEnabled: true,
      backdropTapClosesPanel: true,
      panelBuilder: (ScrollController sc) => _scrollingList(sc),
      body: Center(
        child: Text("This is the Widget behind the sliding panel"),
      ),
    ));
  }

  Widget _scrollingList(ScrollController sc) {
    return ListView.builder(
      controller: sc,
      itemCount: 50,
      itemBuilder: (BuildContext context, int i) {
        return Container(
          color: Colors.red,
          padding: const EdgeInsets.all(12.0),
          child: Text("$i"),
        );
      },
    );
  }

Thank you !

KhatibFX commented 4 years ago

I decided to change the library files until this is solved. I changed the following 2 methods to fix opening and closing:

//close the panel
  Future<void> _close() {
    _scrollingEnabled = false;
    return _ac.fling(velocity: -1.0);
  }

  //open the panel
  Future<void> _open() {
    _scrollingEnabled = true;
    return _ac.fling(velocity: 1.0);
  }