Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Key Widgets
  • UI Components
  • Design & Animations
  • Forms & Gestures
  • Navigation & Routing
  • Flutter Interview Questions
  • Dart
  • Android
  • Kotlin
  • Kotlin Android
  • Android with Java
  • Android Studio
Open In App
Next Article:
Flutter - ColoredBox Class Widget
Next article icon

Flutter – Checkbox Widget

Last Updated : 17 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Checkbox in Flutter is a material design widget. It is always used in the Stateful Widget as it does not maintain its own state. We can use its onChanged property to interact with or modify other widgets in the Flutter app. Like most of the other flutter widgets, it also comes with many properties like activeColor, checkColor, mouseCursor, etc, to let developers have full control over the widget’s look and feel.

Constructor of Checkbox Widget

Checkbox Checkbox({
Key? key,
required bool? value,
bool tristate = false,
required void Function(bool?)? onChanged,
MouseCursor? mouseCursor,
Color? activeColor,
WidgetStateProperty<Color?>? fillColor,
Color? checkColor,
Color? focusColor,
Color? hoverColor,
WidgetStateProperty<Color?>? overlayColor,
double? splashRadius,
MaterialTapTargetSize? materialTapTargetSize,
VisualDensity? visualDensity,
FocusNode? focusNode,
bool autofocus = false,
OutlinedBorder? shape,
BorderSide? side,
bool isError = false,
String? semanticLabel,
})

Properties of Checkbox Widget

Property

Description

activeColor

This property takes the Color class as the object to fill in the CheckBox when it is checked.

autofocus

This property takes in a boolean value as the object. If it is set to true the CheckBox gets selected at the initial focus.

checkColor 

This property also takes in Color class as the object. It assigns color to the check icon.

focusColor

This property also takes in Color class as the object to give color to the checkbox when it is in focus.

focusNode

It sets an additional focus node to get the focus of the cursor. It takes in FocusNode as the object.

hoverColor

The hoverColor property takes in Color class as the object. It controls the color of the checkbox at the time of hover.

materialTapTargetSize

It controls the size of the tapped area. It takes MaterialTapTargetSize enum as the object.

mouseCursor

This determines the cursor type at the time of the pointer event. It holds MouseCursor class as the object.

onChanged

ValueChanged<T> typedef is the object given to this property. It is called when the value in the CheckBox widget should be changed.

tristate

Usually checkbox is either checked or not checked. If this property which takes a boolean as the object is set to true then it can set to null also.

value

This property takes in a boolean value as the object to determine whether the CheckBox is checked or not.

visualDensity

It controls the compactness of CheckBox widget, by taking in the VisualDensity class as the object.

fillColor

Provides control over Checkbox background color.

shape

To customize the shape of the checkbox, you can use the shape property, which takes RoundedRectangleBorder or other shapes.

Example of Checkbox Widget

main.dart:

main.dart
import 'package:flutter/material.dart';  void main() {   runApp(const MyApp()); }  class MyApp extends StatelessWidget {   const MyApp({Key? key}) : super(key: key);    @override   Widget build(BuildContext context) {     return MaterialApp(       home: HomePage(),     );   } }  class HomePage extends StatefulWidget {   @override   _HomePageState createState() => _HomePageState(); }  class _HomePageState extends State<HomePage> {   bool? value = false; // Initialize as nullable bool for null safety    @override   Widget build(BuildContext context) {     return Scaffold(       appBar: AppBar(         title: const Text('GeeksforGeeks'),         backgroundColor: Colors.greenAccent[400],         leading: IconButton(           icon: const Icon(Icons.menu),           tooltip: 'Menu',           onPressed: () {},         ),       ),       body: Center(         child: Card(           child: Padding(             padding: const EdgeInsets.all(15.0),             child: SizedBox(               width: 430,               height: 700,               child: Column(                 children: [                   Text(                     'Algorithms',                     style: TextStyle(                         color: Colors.greenAccent[400],                         fontSize: 30),                   ),                   const SizedBox(height: 10),                   Row(                     children: <Widget>[                       const SizedBox(width: 10),                       const Text(                         'Library Implementation Of Searching Algorithm: ',                         style: TextStyle(fontSize: 17.0),                       ),                       const SizedBox(width: 10),                       Checkbox(                         tristate: true, // Example with tristate                         value: value,                         onChanged: (bool? newValue) {                           setState(() {                             value = newValue;                           });                         },                       ),                     ],                   ),                 ],               ),             ),           ),         ),       ),     );   } } 


Output: 


Explanation of the above Program:

The value property of the CheckBox is set to false at the starting of _HomePageState class. The CheckBox widget is pace in the front of a Text widget separated by a SizedBox inside a Row. The first thing inside the CheckBox widget is calling of the value property. Then we have onChanged property which holding a function to change the state of CheckBox, which makes the CheckBox checked on click. Doing all this we have got a task which can be checked.



Next Article
Flutter - ColoredBox Class Widget
author
ankit_kumar_
Improve
Article Tags :
  • Flutter
  • Flutter
  • Flutter-Widgets

Similar Reads

  • Flutter - Chip Widget
    Chip is a material design widget which comes built-in with flutter. It can simply be described as a compact element holding an icon and text, usually a rounded rectangle in the background. It can serve many purposes, like it can be simply used as a button, representing a user with a CircleAvatar and
    4 min read
  • Flutter - Border Widget
    Border widget in flutter is assigned a simple functionality to add borders to the other widgets. The first is by creating all borders using BorderSide. The second way is by using Border.all to create a uniform border having the same color and width. The third is by using Border.fromBorderSide to cre
    4 min read
  • Flutter - Custom Widgets
    We create Custom Widgets when we want a custom look and feel to our app, and we know that there will be a repetition of a particular widget. We can create the custom widget in a new dart file with all the codes and defining the parameters that we need in the constructor. For more on how to split wid
    8 min read
  • Flutter - Card Widget
    Card is a built-in widget in Flutter which derives its design from Google's Material Design Library. The functionality of this widget on screen is, that it is a bland space or panel with round corners and a slight elevation on the lower side. It comes with many properties like color, shape, shadow c
    4 min read
  • Flutter - ColoredBox Class Widget
    A Colored Box is a container that fills it with color according to its child or A widget that paints its area with a specified Color and then draws its child on top of that color. A sample image is given below to get an idea about what we are going to do in this article. How to use it? You can simpl
    3 min read
  • Flutter - Expanded Widget
    Expanded widget in flutter comes in handy when we want a child widget or children widgets to take all the available space along the main-axis (for Row the main axis is horizontal & vertical for Column).  Expanded widget can be taken as the child of Row, Column, and Flex. And in case if we don't
    5 min read
  • Flutter - Empty Widget
    Empty widget is the flutter widget that is mainly used to notify the user about some event, Like if we are fetching the data from the API or From the database, There may be a case when API returns the null at that moment we can show the empty widget. Also If there is no user internet connection we c
    4 min read
  • Flutter - Flexible Widget
    Flexible is a built-in widget in flutter which controls how a child of base flex widgets that are Row, Column, and Flex will fill the space available to it. The Expanded widget in flutter is shorthand of Flexible with the default fit of FlexFit.tight. Flexible widget plays a very important part in m
    8 min read
  • Flutter - Custom Gradient CheckBox
    Flutter is famous for its UI components and its development. There are many widgets available with multiple properties to customise. Let's create a custom gradient checkbox. A sample video is given below to get an idea about what we are going to do in this article. Checkbox in Flutter is a material
    5 min read
  • Flutter - Banner Widget
    Banner widget comes built-in with flutter API. It is somewhat similar to the debug banner that we are used to seeing on the top-right corner on a flutter app in debug mode. It enables us to show a message or text on top of any other widget. Below we will see its implementation with the help of an ex
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences