How to resolve horizontal drag conflicts between Drawer and bottom view in flutter

41 Views Asked by At

In Flutter, the width of the area where the Drawer is dragged horizontally can be set by setting the DrawerEdgeDragWidth; But when a horizontal drag operation is set in my main view, there will be a conflict between the two, and the horizontal drag operation in my main view will not take effect.

This is my scaffold code:

    return Scaffold(
      drawerEdgeDragWidth: MediaQuery.of(context).size.width,
      body: ScaleTransition(
        scale: Tween<double>(begin: 1.0, end: 0.98)
            .animate(_drawerAnimationController),
        child: Selector<GlobalProvider, bool>(
          selector: (context, globalProvider) => globalProvider.isDrawerOpen,
          builder: (context, isSidebarOpen, _) => PageView(
            controller: _pageController,
            physics: const NeverScrollableScrollPhysics(),
            children: _pageList,
          ),
        ),
      ),
      drawer: _drawer(),
    );

This is the code for my list items that involve horizontal drag event:

    return Dismissible(
      background: DismissibleBackground(
        Icons.add,
        true,
      ),
      secondaryBackground: DismissibleBackground(
        Icons.add,
        false,
      ),
      dismissThresholds: _dismissThresholds,
      confirmDismiss: _onDismiss,
      child: body,
    );

I have tried to understand the mechanism of HitTestBehavior, but it has not had a substantial impact on me.

May I ask what method I can use to prevent the horizontal drag event of the Drawer from taking effect when there is a horizontal drag event consumption in the main view.I am very grateful.

0

There are 0 best solutions below