I am capture the double click in flutter navigate button using GestureDetector
like this way:
return Scaffold(
body: viewService.buildComponent("homelist"),
bottomNavigationBar: GestureDetector(
onDoubleTap: () {
_onItemDoubleTapped();
},
child: BottomNavigationBar(
items: [
BottomNavigationBarItem(icon: Icon(Icons.home), label: AppLocalizations.of(context)!.cruiseNavigatorHome),
BottomNavigationBarItem(icon: Icon(Icons.subscriptions), label: AppLocalizations.of(context)!.cruiseNavigatorSubscribe),
BottomNavigationBarItem(icon: Icon(Icons.rss_feed), label: AppLocalizations.of(context)!.cruiseNavigatorChannel),
BottomNavigationBarItem(icon: Icon(Icons.school), label: AppLocalizations.of(context)!.cruiseNavigatorMine),
],
currentIndex: state.selectIndex,
fixedColor: Theme.of(context).primaryColor,
onTap: _onItemTapped,
unselectedItemColor: Color(0xff666666),
type: BottomNavigationBarType.fixed),
));
double click item trigger _onItemDoubleTapped
event works fine, but now I want to capture the double click of each navigator item. Is it possible to capture the double click event in flutter? I have also tried like this way:
return Scaffold(
body: viewService.buildComponent("homelist"),
bottomNavigationBar: BottomNavigationBar(
items: [
BottomNavigationBarItem(
icon: InkWell(
onDoubleTap: () {
_onItemDoubleTapped();
},
child: Icon(Icons.home)),
label: AppLocalizations.of(context)!.cruiseNavigatorHome),
BottomNavigationBarItem(
icon: InkWell(
onDoubleTap: () {
final SubListDefaultController subListDefaultController = Get.put(SubListDefaultController());
subListDefaultController.isScrollTop = true;
},
child: Icon(Icons.subscriptions)),
label: AppLocalizations.of(context)!.cruiseNavigatorSubscribe),
BottomNavigationBarItem(icon: Icon(Icons.rss_feed), label: AppLocalizations.of(context)!.cruiseNavigatorChannel),
BottomNavigationBarItem(icon: Icon(Icons.school), label: AppLocalizations.of(context)!.cruiseNavigatorMine),
],
currentIndex: state.selectIndex,
fixedColor: Theme.of(context).primaryColor,
onTap: _onItemTapped,
unselectedItemColor: Color(0xff666666),
type: BottomNavigationBarType.fixed),
);
the InkWell
works with double tap but did not trigger the single tap event.
CodePudding user response:
Remove the parent GestureDetector of your BottomNavigationBar and replace inkwell with GestureDetector and then set the behavior of your GestureDetector to HitTestBehavior.translucent.