expandable_bottom_sheet icon indicating copy to clipboard operation
expandable_bottom_sheet copied to clipboard

scroll close not work with list

Open shinewanna opened this issue 4 years ago • 2 comments

if the drag list is reach to top, the bottom sheet should be scroll to close. It work with other widget, just not with list

import 'package:expandable_bottom_sheet/expandable_bottom_sheet.dart';
import 'package:flutter/material.dart';

class SheetTest extends StatefulWidget {
  SheetTest({Key key}) : super(key: key);

  @override
  _SheetTestState createState() => _SheetTestState();
}

class _SheetTestState extends State<SheetTest> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: ExpandableBottomSheet(
        background: Container(
          color: Colors.red,
          child: Center(
            child: Text('Background'),
          ),
        ),
        persistentHeader: Container(
          height: 40,
          color: Colors.blue,
          child: Center(
            child: Text('Header'),
          ),
        ),
        expandableContent: Container(
          height: 500,
          color: Colors.green,
          child: ListView.builder(
            itemCount: 30,
            itemBuilder: (BuildContext context, int index) {
              return ListTile(title: Text('$index'));
            },
          ),
        ),
      ),
    );
  }
}

shinewanna avatar Apr 06 '21 15:04 shinewanna

@shinewanna What exactly do you mean? Can you maybe add a short screen recording so I can understand the problem better?

torbenkeller avatar Apr 08 '21 10:04 torbenkeller

When use a scrollable widget like a ListView inside the expandable_bottom_sheet widget drag gesture not working in these area. I use a workaround with NotificationListening to solve it

NotificationListener<ScrollNotification>(
  onNotification: scrollHandler,
  child: ListView.builder(
    physics: const BouncingScrollPhysics(),
    itemCount: 200,
    itemBuilder: (context, index) {
      return Text('Test');
    }
  ),
),

bool scrollHandler(ScrollNotification notification) {
    if (notification.depth == 0) {
      if (notification is UserScrollNotification) {
        if (notification.metrics.extentBefore == 0 &&
          notification.direction == ScrollDirection.forward
        ) {
          key.currentState!.contract();
        }
      }
    }
    return false;
  }

alejandrogiubel avatar Sep 14 '21 04:09 alejandrogiubel