Disable And Enable Checkbox
Complete Code For Disable And Enable Checkbox In Flutter
main.dart
import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', debugShowCheckedModeBanner: false, home: DisableEnableCheckbox(), ); } } class DisableEnableCheckbox extends StatefulWidget { @override _DisableEnableCheckboxState createState() => _DisableEnableCheckboxState(); } class _DisableEnableCheckboxState extends State<DisableEnableCheckbox> { bool _isChecked = true; bool _isEnabled = true; _onChanged() { setState(() { _isEnabled = !_isEnabled; }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: Colors.indigo, title: Text("Disable & Enable Checkbox"), ), body: Column( children: <Widget>[ Expanded( child: Center( child: CheckboxListTile( title: Text("Checkbox Text"), value: _isChecked, onChanged: _isEnabled ? (val) { setState(() { _isChecked = val; }); } : null, ), ), ), Expanded( child: Center( child: RaisedButton( onPressed: _onChanged, child: Text(_isEnabled ? "Disable" : "Enable",style: TextStyle( color: Colors.white ),), color: Colors.indigo, ), ), ), ], ), ); } }