{"id":7383,"date":"2021-08-08T10:31:32","date_gmt":"2021-08-08T10:31:32","guid":{"rendered":"https:\/\/www.getwidget.dev\/blogs\/flutter-checkbox\/"},"modified":"2024-11-21T11:47:39","modified_gmt":"2024-11-21T11:47:39","slug":"flutter-checkbox","status":"publish","type":"post","link":"https:\/\/www.getwidget.dev\/blog\/flutter-checkbox\/","title":{"rendered":"How to Design Custom Checkbox in Flutter with Getwidget"},"content":{"rendered":"<p><strong>Flutter Checkbox <\/strong>is used when we have lists of options and the user can select any number of choices.<\/p>\n<p><a href=\"https:\/\/docs.getwidget.dev\/gf-checkbox\/\" target=\"_blank\" rel=\"noopener\"><strong>Flutter Checkbox<\/strong><\/a> is a GUI(Graphical User Interface) which allows the user to do a binary choice between yes and no options. This is alternatively a choice between possible outcomes i.e. if the user has a yes\/no outcome there we can show the checkbox as checked\/unchecked. Users can also use its customized properties to make it elegant.<\/p>\n<p>In Flutter, we can define a Checkbox of widgets inside the scaffold. Therefore before adding a Checkbox of a widget, we need to define a Scaffold. When we creating a sample flutter app, it comes with the default scaffold.<\/p>\n<h3 id=\"gf-checkbox-widget-for-flutter\">GF Checkbox Widget for Flutter<\/h3>\n<p>It allows you to speed up your <a href=\"https:\/\/www.ionicfirebaseapp.com\/flutter-app-development-company\" target=\"_blank\" rel=\"noopener\">Flutter app development<\/a> by 20-30%. It has almost all widget that allows you to enhance your Flutter UI design and speed up flutter development with fully customizable features.<\/p>\n<blockquote><p><em>Now here is i am going to talk about what is <strong>GetWidget<\/strong> Checkbox widget and how we implement this on Flutter app to build awesome Flutter Checkbox widget for an app.<\/em><\/p><\/blockquote>\n<p>So, are you ready to make use of this widget package in the Flutter application? If so, then let&#8217;s quickly jump into the usage and the ways a Checkbox can be modified and used to make user-friendly apps. Here I am going to use an open-source UI Library known as GetWidget to build this Checkbox <a href=\"https:\/\/www.getwidget.dev\/blog\/what-is-widget-in-flutter\/\" data-wpil-monitor-id=\"221\">widget in Flutter<\/a>.<\/p>\n<h3 id=\"how-to-get-started\">How to Get Started<\/h3>\n<p>Now here is the guide about how we should start developing <a href=\"https:\/\/docs.getwidget.dev\/gf-checkbox\/\" target=\"_blank\" rel=\"noopener\"><strong>GFCheckbox<\/strong><\/a> Widget with the use of <strong>GetWidget<\/strong> UI Library.<\/p>\n<p><a href=\"https:\/\/docs.getwidget.dev\/getting-started\/\" target=\"_blank\" rel=\"noopener\"><strong>Getting started<\/strong><\/a> will guide you on how to start building a beautiful flutter application with <strong>GetWidget<\/strong> UI library. You have to install the package from <strong>pub.dev<\/strong>, import the package in your Flutter project.<\/p>\n<blockquote><p><em>Install Package from pub.dev :<\/em><\/p><\/blockquote>\n<p><a href=\"https:\/\/pub.dev\/packages\/getwidget\/\" target=\"_blank\" rel=\"noopener\"><strong>https:\/\/pub.dev\/packages\/getwidget<\/strong><\/a><\/p>\n<h3 id=\"import-full-package\">Import full package:<\/h3>\n<p>import &#8216;package:getwidget\/getwidget.dart&#8217;;<\/p>\n<p><strong>Note: dependencies: getwidget: ^ 4.0.0<\/strong><\/p>\n<blockquote><p><em>Keep playing with the pre-built UI components.<\/em><\/p><\/blockquote>\n<p><strong>GFCheckBox<\/strong> is a <strong>Flutter Checkbox<\/strong> that is a material widget that allows users to select one option from the set of given options. The user can select one or multiple at a time depending on the situation. The checkbox is a binary value with yes and no. The value is checked if it is yes and unchecked if it is no.<\/p>\n<p>Let us now see the different types of GFCheckBox in the below section<\/p>\n<h3 id=\"flutter-basic-checkbox\">Flutter Basic Checkbox<\/h3>\n<p>This is a basic or standard type of checkbox.\u200c It has a slight border radius around it. By using the below code we can design a basic Checkbox.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" class=\"kg-image lazyload\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" data-src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/getwidget\/\/2023\/04\/MicrosoftTeams-image--107-.png\" alt=\"\" width=\"725\" height=\"208\" \/><noscript><img decoding=\"async\" class=\"kg-image lazyload\" src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/getwidget\/\/2023\/04\/MicrosoftTeams-image--107-.png\" alt=\"\" width=\"725\" height=\"208\" \/><\/noscript><\/figure>\n<figure class=\"kg-card kg-code-card\">\n<pre><code class=\"language-javascript\">bool isChecked = false;\n\nGFCard(\n content: Row(\n mainAxisAlignment: MainAxisAlignment.spaceBetween,\n children: [\n   GFCheckbox(\n     activeBgColor: Colors.red,\n     onChanged: (value) {\n       setState(() {\n         isChecked = value;\n       });\n     },\n     value: isChecked,\n     inactiveIcon: null,\n   ),\n  GFCheckbox(\n    activeBgColor: Colors.blue,\n    onChanged: (value) {\n      setState(() {\n        isChecked = value;\n      });\n    },\n    value: isChecked,\n    inactiveIcon: null,\n   ),\n   GFCheckbox(\n     size: GFSize.SMALL,\n     activeBgColor: Colors.green,\n     onChanged: (value) {\n       setState(() {\n         isChecked = value;\n       });\n     },\n     value: isChecked,\n     inactiveIcon: null,\n    ),\n   ],\n  ),\n),<\/code><\/pre><figcaption><span style=\"white-space: pre-wrap;\">Flutter Simple checkbox<\/span><\/p>\n<\/figcaption><\/figure>\n<h3 id=\"flutter-square-checkbox\">Flutter Square Checkbox<\/h3>\n<p>This is a square type of checkbox.\u200c It doesn&#8217;t have any border radius. We use GFCheckboxType.square to make it of type square. Use the below code to make a square Checkbox.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" class=\"kg-image lazyload\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" data-src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/getwidget\/\/2023\/04\/MicrosoftTeams-image--107--1.png\" alt=\"\" width=\"725\" height=\"208\" \/><noscript><img decoding=\"async\" class=\"kg-image lazyload\" src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/getwidget\/\/2023\/04\/MicrosoftTeams-image--107--1.png\" alt=\"\" width=\"725\" height=\"208\" \/><\/noscript><\/figure>\n<figure class=\"kg-card kg-code-card\">\n<pre><code class=\"language-javascript\">bool isChecked = true;\n\nGFCard(\n  content: Row(\n    mainAxisAlignment: MainAxisAlignment.spaceBetween,\n    children: [\n      GFCheckbox(\n        size: GFSize.LARGE,\n        activeBgColor: Colors.red,\n        type: GFCheckboxType.square,\n        onChanged: (value) {\n          setState(() {\n            isChecked = value;\n          });\n        },\n        value: isChecked,\n        inactiveIcon: null,\n      ),\n      GFCheckbox(\n        type: GFCheckboxType.square,\n        activeBgColor: Colors.blue,\n        onChanged: (value) {\n          setState(() {\n            isChecked = value;\n          });\n        },\n        value: isChecked,\n        inactiveIcon: null,\n      ),\n      GFCheckbox(\n        size: GFSize.SMALL,\n        activeBgColor: Colors.green,\n        type: GFCheckboxType.square,\n        onChanged: (value) {\n          setState(() {\n            isChecked = value;\n          });\n        },\n        value: isChecked,\n        inactiveIcon: null,\n      ),\n    ],\n  ),\n),<\/code><\/pre><figcaption><span style=\"white-space: pre-wrap;\">Flutter Square checkbox widget<\/span><\/p>\n<\/figcaption><\/figure>\n<h3 id=\"flutter-circular-checkbox\">Flutter Circular Checkbox<\/h3>\n<p>This is a circular type checkbox.\u200c The shape is of a circle or round as shown in the below image. Add type GFCheckboxType.circle to make it a circle.<\/p>\n<p>Use the below example to show the Flutter circular Checkbox.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" class=\"kg-image lazyload\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" data-src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/getwidget\/\/2023\/04\/MicrosoftTeams-image--108-.png\" alt=\"\" width=\"725\" height=\"209\" \/><noscript><img decoding=\"async\" class=\"kg-image lazyload\" src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/getwidget\/\/2023\/04\/MicrosoftTeams-image--108-.png\" alt=\"\" width=\"725\" height=\"209\" \/><\/noscript><\/figure>\n<figure class=\"kg-card kg-code-card\">\n<pre><code class=\"language-javascript\">bool isChecked = false;\n\nGFCard(\n  content: Row(\n    mainAxisAlignment: MainAxisAlignment.spaceBetween,\n    children: [\n      GFCheckbox(\n        size: GFSize.LARGE,\n        activeBgColor: Colors.red,\n        type: GFCheckboxType.circle,\n        onChanged: (value) {\n          setState(() {\n            isChecked = value;\n          });\n        },\n        value: isChecked,\n        inactiveIcon: null,\n      ),\n      GFCheckbox(\n        type: GFCheckboxType.circle,\n        activeBgColor: Colors.blue,\n        onChanged: (value) {\n          setState(() {\n            isChecked = value;\n          });\n        },\n        value: isChecked,\n      ),\n      GFCheckbox(\n        activeBgColor: Colors.green,\n        size: GFSize.MEDIUM,\n        type: GFCheckboxType.circle,\n        onChanged: (value) {\n          setState(() {\n            isChecked = value;\n          });\n        },\n        value: isChecked,\n        inactiveIcon: null,\n      ),\n    ],\n  ),\n),<\/code><\/pre><figcaption><span style=\"white-space: pre-wrap;\">Flutter Circular Checkbox Widget\u00a0<\/span><\/p>\n<\/figcaption><\/figure>\n<h3 id=\"flutter-custom-checkbox-widget-with-icon\">Flutter Custom Checkbox Widget With Icon<\/h3>\n<p>The <strong>Custom CheckBox<\/strong> can have an icon or background image as the check value shown in the image below. We can customize the widget by using its property. Use the below example to make a custom Checkbox.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" class=\"kg-image lazyload\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" data-src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/getwidget\/\/2023\/04\/MicrosoftTeams-image--109-.png\" alt=\"\" width=\"725\" height=\"208\" \/><noscript><img decoding=\"async\" class=\"kg-image lazyload\" src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/getwidget\/\/2023\/04\/MicrosoftTeams-image--109-.png\" alt=\"\" width=\"725\" height=\"208\" \/><\/noscript><\/figure>\n<figure class=\"kg-card kg-code-card\">\n<pre><code class=\"language-javascript\">bool isChecked = true;\n\nGFCard(\n  content: Row(\n    mainAxisAlignment: MainAxisAlignment.spaceBetween,\n    children: [\n      GFCheckbox(\n        size: GFSize.LARGE,\n        type: GFCheckboxType.custom,\n        onChanged: (value) {\n          setState(() {\n            isChecked = value;\n          });\n        },\n        value: isChecked,\n        inactiveIcon: null,\n      ),\n      GFCheckbox(\n        type: GFCheckboxType.square,\n        activeBgColor: Colors.purple,\n        activeIcon: Icon(Icons.sentiment_satisfied),\n        onChanged: (value) {\n          setState(() {\n            isChecked = value;\n          });\n        },\n        value: isChecked,\n        inactiveIcon: Icon(Icons.sentiment_dissatisfied),\n      ),\n      GFCheckbox(\n        size: GFSize.SMALL,\n        type: GFCheckboxType.custom,\n        onChanged: (value) {\n          setState(() {\n            isChecked = value;\n          });\n        },\n        value: isChecked,\n        custombgColor: Colors.blue,\n      ),\n    ],\n  ),\n),<\/code><\/pre><figcaption><span style=\"white-space: pre-wrap;\">Flutter Custom Checkbox Widget<\/span><\/p>\n<\/figcaption><\/figure>\n<h3 id=\"flutter-checkbox-widget-custom-properties\">Flutter Checkbox Widget Custom Properties<\/h3>\n<p>The look and feel of the <a href=\"https:\/\/docs.getwidget.dev\/gf-checkbox\/\" target=\"_blank\" rel=\"noopener\"><strong>Flutter Checkbox<\/strong><\/a> can be customized using the GFCheckbox properties.<\/p>\n<table>\n<thead>\n<tr>\n<th><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>type<\/strong><\/td>\n<td>type of [GFCheckboxType] which is of four type is basic, square, circular and custom<\/td>\n<\/tr>\n<tr>\n<td><strong>size<\/strong><\/td>\n<td>type of [double] which is GFSize ie, small, medium and large and can use any double value<\/td>\n<\/tr>\n<tr>\n<td><strong>activeBgColor<\/strong><\/td>\n<td>type of [Color] used to change the backgroundColor of the active checkbox<\/td>\n<\/tr>\n<tr>\n<td><strong>inactiveBgColor<\/strong><\/td>\n<td>type of [Color] used to change the backgroundColor of the inactive checkbox<\/td>\n<\/tr>\n<tr>\n<td><strong>activeBorderColor<\/strong><\/td>\n<td>type of [Color] used to change the border color of the active checkbox<\/td>\n<\/tr>\n<tr>\n<td><strong>inactiveBorderColor<\/strong><\/td>\n<td>type of [Color] used to change the border color of the inactive checkbox<\/td>\n<\/tr>\n<tr>\n<td><strong>onChanged<\/strong><\/td>\n<td>called when the user checks or unchecks the checkbox.<\/td>\n<\/tr>\n<tr>\n<td><strong>value<\/strong><\/td>\n<td>used to set the current state of the checkbox<\/td>\n<\/tr>\n<tr>\n<td><strong>activeIcon<\/strong><\/td>\n<td>type of [Widget] used to change the checkbox&#8217;s active icon<\/td>\n<\/tr>\n<tr>\n<td><strong>inactiveIcon<\/strong><\/td>\n<td>type of [Widget] used to change the checkbox&#8217;s inactive icon<\/td>\n<\/tr>\n<tr>\n<td><strong>customBgColor<\/strong><\/td>\n<td>type of [Color] used to change the background color of the custom active checkbox only<\/td>\n<\/tr>\n<tr>\n<td><strong>autofocus<\/strong><\/td>\n<td>on true state this widget will be selected as the initial focus when no other node in its scope is currently focused<\/td>\n<\/tr>\n<tr>\n<td><strong>focusNode<\/strong><\/td>\n<td>an optional focus node to use as the focus node for this widget.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"can-we-change-the-tick-mark\"><strong>Can we change the tick mark?<\/strong><\/h3>\n<p>Yes, we can change the tick mark by using its customizable property.<\/p>\n<h3 id=\"how-to-change-the-size-of-the-checkbox\">How to change the size of the CheckBox<\/h3>\n<p>The size can be changed using the size property and the <a href=\"https:\/\/docs.getwidget.dev\/gf-checkbox\/\" target=\"_blank\" rel=\"noopener\">GFCheckBox<\/a> has small, medium, and large by default. The user can also change according to the need by giving the double value.<\/p>\n<p><a href=\"https:\/\/docs.getwidget.dev\/\" target=\"_blank\" rel=\"noopener\"><strong>Flutter Get Widget Docs<\/strong><\/a><\/p>\n<figure class=\"kg-card kg-bookmark-card\">\n<div class=\"kg-bookmark-content\">\n<div class=\"kg-bookmark-title\">Flutter GetWidget Docs<\/div>\n<div class=\"kg-bookmark-description\">Get Widget is one of the largest Flutter open-source UI Kit libraries for mobile or web apps. It has more than 1000+ pre-built reusable widgets.<\/div>\n<div class=\"kg-bookmark-metadata\"><img decoding=\"async\" class=\"kg-bookmark-icon lazyload\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" data-src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/favicon_QkjfdlGz1.png\" alt=\"\" \/><noscript><img decoding=\"async\" class=\"kg-bookmark-icon lazyload\" src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/favicon_QkjfdlGz1.png\" alt=\"\" \/><\/noscript><span class=\"kg-bookmark-author\">getwidget<\/span><span class=\"kg-bookmark-publisher\">getwidget<\/span><\/div>\n<\/div>\n<div class=\"kg-bookmark-thumbnail\"><img decoding=\"async\" class=\"lazyload\" src=\"data:image\/gif;base64,R0lGODlhAQABAIAAAAAAAP\/\/\/yH5BAEAAAAALAAAAAABAAEAAAIBRAA7\" data-src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/docs\/tr:dpr-auto,tr:w-auto\/link-share_aT-cHzGY9.png\" alt=\"\" \/><noscript><img decoding=\"async\" class=\"lazyload\" src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/docs\/tr:dpr-auto,tr:w-auto\/link-share_aT-cHzGY9.png\" alt=\"\" \/><\/noscript><\/div>\n<\/figure>\n<p><a href=\"https:\/\/github.com\/ionicfirebaseapp\/getwidget\/\" target=\"_blank\" rel=\"noopener\"><strong>GitHub Repository<\/strong><\/a>: Please do appreciate our work through Github start<\/p>\n<h3 id=\"conclusion\">Conclusion:<\/h3>\n<p>Here we discuss, what <a href=\"https:\/\/docs.getwidget.dev\/gf-checkbox\/\" target=\"_blank\" rel=\"noopener\"><strong>Flutter CheckBox<\/strong><\/a> Widget is? And how we can use and implement it into our Flutter app through the <strong>GetWidget<\/strong> CheckBox component. Here, there are options to customize and use other types of CheckBox.<\/p>\n<h3 id=\"about-our-team\">About Our Team:<\/h3>\n<p>We have been working on Flutter since Flutter launched in beta version in 2017. And our team have been putting hundreds and hundreds of hour into the experiment and implementation of Flutter. As well as after the successful delivery of enterprise and SAAS applications that have been used by more than 500+ businesses around the 119+ countries. Now we are in love with Flutter development and we are very passionate about Flutter development. Now it is something we are trying to give a small contribution to the <a href=\"https:\/\/www.getwidget.dev\/\" rel=\"noreferrer\">Flutter Dev Community<\/a>. If you need assistance for your next app development project you can <a href=\"https:\/\/www.getwidget.dev\/hire-flutter-developer\"><strong>hire flutter developer<\/strong><\/a> from the <strong>GetWidget<\/strong> team<\/p>\n","protected":false},"excerpt":{"rendered":"Flutter Checkbox is used when we have lists of options and the user can select any number of&hellip;","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"csco_display_header_overlay":false,"csco_singular_sidebar":"","csco_page_header_type":"","footnotes":""},"categories":[139],"tags":[],"class_list":{"0":"post-7383","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-flutter","7":"cs-entry"},"_links":{"self":[{"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/posts\/7383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/comments?post=7383"}],"version-history":[{"count":3,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/posts\/7383\/revisions"}],"predecessor-version":[{"id":8643,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/posts\/7383\/revisions\/8643"}],"wp:attachment":[{"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/media?parent=7383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/categories?post=7383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/tags?post=7383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}