Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is conflict with TabBar&TabBarView #10

Open
houleixx opened this issue Jan 5, 2021 · 3 comments
Open

It is conflict with TabBar&TabBarView #10

houleixx opened this issue Jan 5, 2021 · 3 comments

Comments

@houleixx
Copy link

houleixx commented Jan 5, 2021

It is conflict with TabBar&TabBarView。
It is conflict with ListView( scrollDirection : Axis.horizontal)。

@emvaized
Copy link

emvaized commented Jan 5, 2021

I guess you should implement your own GestureArena, like described in this article:
https://medium.com/koahealth/combining-multiple-gesturedetectors-in-flutter-26d899d008b2

@SteveJob
Copy link

It is conflict with TabBar&TabBarView。
It is conflict with ListView( scrollDirection : Axis.horizontal)。

Has the problem been solved now?

@ivanbogomoloff
Copy link

Workaround is RawGestureDetector with hardcoded swipe zone.

child: RawGestureDetector(
                        gestures: {
                          AllowMultipleGestureRecognizer:
                          GestureRecognizerFactoryWithHandlers<
                              AllowMultipleGestureRecognizer>(
                                () => AllowMultipleGestureRecognizer(),  //constructor
                                (AllowMultipleGestureRecognizer instance) {

                              instance.onCancel = () {
                                setState(() {
                                  _tabPhysics = const ScrollPhysics();
                                });
                              };
                              instance.onDown = (position) {
                                setState(() {
                                  /// 199 - it's magic left side zone on screen. I think it can be about 200-250 in my case it's ok.
                                  if(_tabController!.index == 0 && position.localPosition.dx <= 199) {
                                      _tabPhysics = const NeverScrollableScrollPhysics();
                                  } else {
                                    _tabPhysics = const ScrollPhysics();
                                  }
                                });
                              };
                            },
                          )
                        },
                      child: TabBarView(
                        physics: _tabPhysics,
                        controller: _tabController,
                        children: tabs.map((tab) => AdvertListWidget(items: tab.items)).toList(),
                      ),
                    )
//
class AllowMultipleGestureRecognizer extends VerticalDragGestureRecognizer
{
  @override
  void rejectGesture(int pointer) {

    acceptGesture(pointer);
  }
}

And in _tabController i change physics

_tabController!.addListener(() {
   setState(() {
      _tabPhysics = const ScrollPhysics();
    });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants