I have some IconButton in persistentFooterButtons that navigate to other screens but if I pressed double on any button and press the back button it redirects two times. if I pressed the button multiple times and press the back button it shows me the same page. so I want to click only one time and when it clicks and shows me the page the button will disable and won't press I think it works but I know how do I do that. please help me with that issue.
Here is my code:-
class Footer extends StatefulWidget {
Footer({Key? key}) : super(key: key);
@override
_Footer createState() => _Footer();
}
class _Footer extends State<Footer>{
bool _isButtonTapped1 = false;
bool _isButtonTapped2 = false;
bool _isButtonTapped3 = false;
bool _isButtonTapped4 = false;
@override
Widget build(BuildContext context){
return MaterialApp(
home: Scaffold(
appBar: AppBar()
persistentFooterButtons: [
Row(
children: [
IconButton(
onPressed: () {
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => const CardApp()),
(Route<dynamic> route) => false);
},
icon: SvgPicture.asset(
'assets/images/f_home.svg',
),
),
Spacer(),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Matches()),
);
},
icon: SvgPicture.asset(
'assets/images/f_fav.svg',
),
),
Spacer(),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Message()),
);
},
icon: SvgPicture.asset(
'assets/images/f_chat.svg',
),
),
Spacer(),
IconButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => Favorites()),
);
},
icon: SvgPicture.asset(
'assets/images/f_star.svg',
),
),
]
)
],
),
);
}
}
Here is my code of persistentFooterButtons which added four buttons and each button navigates its own screen.
please help me ho disable multiple onPressed on every button. if anyone knows please help me out
if you want to prevent multiple press from user, in InkWell widget, use this: onDoubleTap: (){},