CheckboxListTile

 import "package:flutter/material.dart";


void main()
{
runApp(const MyApp());
}
class MyApp extends StatelessWidget
{
const MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: "CheckBoxListTile",
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.grey,
),
home: const CheckPractice(),
);
}
}
class CheckPractice extends StatefulWidget
{
const CheckPractice({super.key});

@override
State<CheckPractice> createState() => _CheckPracticeState();
}

class _CheckPracticeState extends State<CheckPractice> {

/// value set to false
bool _value1 = false;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("CheckBoxListTile"),
centerTitle: true,
backgroundColor: Colors.grey,
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: 500.0,
decoration: BoxDecoration(
border: Border.all(color: Colors.brown),
borderRadius: BorderRadius.circular(20.0),
),
child: CheckboxListTile(
title: const Text("CheckboxListTile 1", style: TextStyle(fontWeight: FontWeight.bold),),
subtitle: const Text("CheckboxListTile is a built-in widget in flutter. We can say it a combination"
" of CheckBox with a ListTile. Its properties such as value, activeColor, and"
" checkColor are similar to the CheckBox widget, and title, subtitle,"
" contentPadding, etc are similar to the ListTile widget."),
secondary: const CircleAvatar(
backgroundImage: NetworkImage(
"https://upload.wikimedia.org/wikipedia/commons/b/b6/Image_created_with_a_mobile_phone.png"),
radius: 20.0,
),
autofocus: false,
isThreeLine: true,
activeColor: Colors.green,
selected: _value1,
// dense: true,
value: _value1,
onChanged: (value) {
setState(() {
_value1 = value!;
});
},
),
),
],
),
),
);
}
}

///Properties of CheckboxListTile Widget:
//
/// activeColor: This widget takes in the Color class as the object to assign the checkbox a color
/// when it is checked.
// autofocus: This property takes in a boolean as the value to divide whether the widget will be
// selected on the initial focus or not.
/// checkColor: This property assigns a color to the check icon by taking in the Color class as the object.
// contentPadding: This property is responsible to assign empty space inside the widget by taking
// in EdgeInsetsGeometry class as the object.
/// controlAffinity: The controlAffinity property holds the ListTileControlAffinity class as the
/// object to decide the location of action in respect to text inside the widget.
// dense: The dense property takes in a boolean as the object whether is associated with the
// vertical dense list.
/// isThreeLine: This property also takes in a boolean as the object to decide whether the text
/// in the widget will be printed till the third line.
// onChanged: This property takes in Valuechanged<bool> as the object. This property is responsible
// for the change in the checkbox.
/// secondary: The secondary property holds a widget as the object to be displayed on the opposite
/// side of the checkbox.
// selected: This property takes in a boolean value as the object to decide whether the checkbox
// will be already selected or not.
/// subtitle: The subtitle property holds a widget as the object to be displayed below the title.
/// Usually, this widget is Text.
// title: This property also takes in a widget as the object to be displayed as the title of the
// CheckBoxListTile, usually, it is Text widget.
/// tristate: This property holds a boolean as the object. If it is set to true the values in the
/// checkbox can either true, false, or null.
// value: This property also takes in a boolean as the object to control whether the checkbox is
// selected or not.

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter