Advertisement
k4ilham

flutter checkbox

Jul 17th, 2021
1,069
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.41 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. class CheckBoxWidget extends StatefulWidget {
  4.   @override
  5.   _CheckBoxWidgetState createState() => _CheckBoxWidgetState();
  6. }
  7.  
  8. class _CheckBoxWidgetState extends State<CheckBoxWidget> {
  9.   bool _checkBoxVal = true;
  10.  
  11.   @override
  12.   Widget build(BuildContext context) {
  13.     return Column(
  14.       mainAxisAlignment: MainAxisAlignment.center,
  15.       children: <Widget>[
  16.         Row(
  17.           mainAxisAlignment: MainAxisAlignment.center,
  18.           children: <Widget>[
  19.             Center(
  20.               child: Checkbox(
  21.                 activeColor: Colors.black,
  22.                 onChanged: (bool value) {
  23.                   setState(() => this._checkBoxVal = value);
  24.                 },
  25.                 value: this._checkBoxVal,
  26.               ),
  27.             ),
  28.             SizedBox(
  29.               width: 20,
  30.             ),
  31.             Text(
  32.               "Checkbox : $_checkBoxVal",
  33.               style: TextStyle(fontSize: 25),
  34.             ),
  35.           ],
  36.         ),
  37.         Row(
  38.           mainAxisAlignment: MainAxisAlignment.center,
  39.           children: <Widget>[
  40.             Checkbox(
  41.               tristate: true,
  42.               onChanged: null,
  43.               value: null,
  44.             ),
  45.             SizedBox(
  46.               width: 20,
  47.             ),
  48.             Text(
  49.               "Checkbox : false",
  50.               style: TextStyle(fontSize: 25),
  51.             ),
  52.           ],
  53.         ),
  54.       ],
  55.     );
  56.   }
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement