Prevent Button Double Tap
Complete Code For Prevent Button Double Tap In Flutter
main.dart
import 'package:flutter/material.dart'; void main(){ runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { @override MyHomePageState createState() { return new MyHomePageState(); } } class MyHomePageState extends State<MyHomePage> { bool _isButtonTapped = false; _onTapped() { setState(() => _isButtonTapped = !_isButtonTapped); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.deepPurple[900], title: Text('Prevent Button Double Tap'), ), body: Center( child: RaisedButton( color: Colors.deepPurple[900], child: Text('Tap Once',style: TextStyle(color: Colors.white),), onPressed: _isButtonTapped ? null : _onTapped, ), ), ); } }