{"id":7384,"date":"2021-08-08T11:58:59","date_gmt":"2021-08-08T11:58:59","guid":{"rendered":"https:\/\/www.getwidget.dev\/blogs\/flutter-radio-button\/"},"modified":"2024-11-21T11:51:47","modified_gmt":"2024-11-21T11:51:47","slug":"flutter-radio-button","status":"publish","type":"post","link":"https:\/\/www.getwidget.dev\/blog\/flutter-radio-button\/","title":{"rendered":"Flutter Radio Button &#8211; A graphically control element that allows the user to choose one among a predefined list."},"content":{"rendered":"<p><a href=\"https:\/\/docs.getwidget.dev\/gf-radio\/\" target=\"_blank\" rel=\"noopener\"><strong>Flutter Radio Button<\/strong><\/a> allows users to make a choice among a list. We are likely to use this where you have to pick only one option among a list.<\/p>\n<p><strong>Flutter Radio <\/strong>is a GUI(Graphical User Interface) which allows the user to do a binary choice. This is alternatively a choice among possible outcomes i.e. if the user has a yes\/no outcome there we can show Radio as checked\/unchecked. Radio can be checked only once. Users can also use its customized properties to make it elegant. This is basically a rounded border with having a solid circle inside it , when it is checked otherwise it&#8217;s just a blank rounded border.<\/p>\n<p>In Flutter, we can define the Radio of widgets inside the scaffold. Therefore before adding a Radio 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=\"radio-button-widget-in-flutter-with-example\">Radio Button Widget in Flutter With Example<\/h3>\n<p><em> I am going to talk about what is <strong>GetWidget<\/strong> Radio widget is and how we implement this on the Flutter app to build an awesome Flutter Radio widget for an app.<\/em><\/p>\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 Radio can be modified and used to make user-friendly apps. Here I am going to use an open-source <a href=\"https:\/\/www.getwidget.dev\/\">flutter UI Library<\/a> known as GetWidget to build this Radio option widget in Flutter.<\/p>\n<h3 id=\"how-to-start\">How to Start:<\/h3>\n<p>Now here is the guide about how we should start developing <strong>GFRadio <\/strong>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>GFRadio Button<\/strong> is a<strong> Flutter Radio Button<\/strong> that is a material widget that has a binary value of yes or no. The user can select only one value at a time in the given set of options. The checked value will be a yes and the unchecked value will be a no.<\/p>\n<p><strong>Also Read &#8211; <a href=\"https:\/\/www.getwidget.dev\/blog\/choosing-right-flutter-app-development-company\/\">How to Choose the Right Flutter App Development Company: A Comprehensive Guide<\/a><\/strong><\/p>\n<p>Let us now see the different types of GFRadio buttons in the below section<\/p>\n<h3 id=\"basic-flutter-radio-button-example-code\">Basic Flutter Radio Button Example Code<\/h3>\n<p>This is a basic type of radio button that is circular in shape and has a dot for the checked and blank for the unchecked options.<\/p>\n<p>Let us see the radio button in <a href=\"https:\/\/www.ionicfirebaseapp.com\/blogs\/best-flutter-app-examples\/\" target=\"_blank\" rel=\"noopener\">flutter examples<\/a> below.<\/p>\n<p>By using the below code we can design a basic Radio button in GFRadio.<\/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--98-.png\" alt=\"\" width=\"725\" height=\"283\" \/><noscript><img decoding=\"async\" class=\"kg-image lazyload\" src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/getwidget\/\/2023\/04\/MicrosoftTeams-image--98-.png\" alt=\"\" width=\"725\" height=\"283\" \/><\/noscript><\/figure>\n<figure class=\"kg-card kg-code-card\">\n<pre><code class=\"language-javascript\">int groupValue = 0;\n\nGFCard(\n    content: Row(\n      mainAxisAlignment: MainAxisAlignment.spaceBetween,\n      children: [\n        GFRadio(\n          size: GFSize.LARGE,\n          activeBorderColor: Colors.green,\n          value: 0,\n          groupValue: groupValue,\n          onChanged: (val) {\n            setState(() {\n              groupValue = value;\n            });\n          },\n          inactiveIcon: null,\n          radioColor: Colors.green,\n        ),\n        GFRadio(\n          size: GFSize.MEDIUM,\n          value: 1,\n          groupValue: groupValue,\n          onChanged: (value) {\n            setState(() {\n              groupValue = value;\n            });\n          },\n          inactiveIcon: null,\n          activeBorderColor: Colors.green,\n          radioColor: Colors.green,\n        ),\n        GFRadio(\n          size: GFSize.SMALL,\n          value: 2,\n          groupValue: groupValue,\n          onChanged: (value) {\n            setState(() {\n              groupValue = value;\n            });\n          },\n          inactiveIcon: null,\n          activeBorderColor: Colors.green,\n          radioColor: Colors.green,\n        ),\n        GFRadio(\n          size: 20,\n          value: 3,\n          groupValue: groupValue,\n          onChanged: (value) {\n            setState(() {\n              groupValue = value;\n            });\n          },\n          inactiveIcon: null,\n          activeBorderColor: Colors.green,\n          radioColor: Colors.green,\n        )\n      ],\n    )),<\/code><\/pre><figcaption><span style=\"white-space: pre-wrap;\">Basic Custom Flutter radio option button\u00a0<\/span><\/p>\n<\/figcaption><\/figure>\n<h3 id=\"flutter-square-radio-button-design-with-example-code\">Flutter Square Radio button design with example code<\/h3>\n<p>This is a <strong>square type<\/strong> of Radio.\u200c Here the border is of type square but the inside child is a solid circle. Use the below code to make a custom square Radio Button.<\/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--99-.png\" alt=\"\" width=\"725\" height=\"283\" \/><noscript><img decoding=\"async\" class=\"kg-image lazyload\" src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/getwidget\/\/2023\/04\/MicrosoftTeams-image--99-.png\" alt=\"\" width=\"725\" height=\"283\" \/><\/noscript><\/figure>\n<figure class=\"kg-card kg-code-card\">\n<pre><code class=\"language-javascript\">int groupValue = 0;\n\nGFCard(\n    content: Row(\n      mainAxisAlignment: MainAxisAlignment.spaceBetween,\n      children: [\n        GFRadio(\n          type: GFRadioType.square,\n          size: GFSize.LARGE,\n          value: 1,\n          groupValue: groupValue,\n          onChanged: (value) {\n            setState(() {\n              groupValue = value;\n            });\n          },\n          inactiveIcon: null,\n          activeBorderColor: Colors.green,\n          radioColor: Colors.green,\n        ),\n        GFRadio(\n          type: GFRadioType.square,\n          size: GFSize.MEDIUM,\n          value: 2,\n          groupValue: groupValue,\n          onChanged: (value) {\n            setState(() {\n              groupValue = value;\n            });\n          },\n          inactiveIcon: null,\n          activeBorderColor: Colors.green,\n          radioColor: Colors.green,\n        ),\n        GFRadio(\n          type: GFRadioType.square,\n          size: GFSize.SMALL,\n          value: 3,\n          groupValue: groupValue,\n          onChanged: (value) {\n            setState(() {\n              groupValue = value;\n            });\n          },\n          inactiveIcon: null,\n          activeBorderColor: Colors.green,\n          radioColor: Colors.green,\n        ),\n        GFRadio(\n          type: GFRadioType.square,\n          size: 20,\n          value: 7,\n          groupValue: groupValue,\n          onChanged: (value) {\n            setState(() {\n              groupValue = value;\n            });\n          },\n          inactiveIcon: null,\n          activeBorderColor: Colors.green,\n          radioColor: Colors.green,\n        )\n      ],\n    )),<\/code><\/pre><figcaption><span style=\"white-space: pre-wrap;\">Flutter Square Radio button with example Code snippet\u00a0<\/span><\/p>\n<\/figcaption><\/figure>\n<h3 id=\"custom-flutter-radio-button-design-with-example-code\">Custom Flutter Radio Button Design with example code<\/h3>\n<p><strong>Custom radio button <\/strong>is a type of radio button where-in, the user can cutomize the radio button according to the needs of the application.This is a custom type of Radio.\u200c It can have icons as the checked value according to the requirement to make the look of the radio more attractive to the user. We can customize the widget by using its property. Use the below example to make a custom Radio.<\/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--100-.png\" alt=\"\" width=\"725\" height=\"638\" \/><noscript><img decoding=\"async\" class=\"kg-image lazyload\" src=\"https:\/\/ik.imagekit.io\/ionicfirebaseapp\/getwidget\/\/2023\/04\/MicrosoftTeams-image--100-.png\" alt=\"\" width=\"725\" height=\"638\" \/><\/noscript><\/figure>\n<figure class=\"kg-card kg-code-card\">\n<pre><code class=\"language-javascript\">int groupValue = 0;\n\nGFCard(\n    content: Row(\n      mainAxisAlignment: MainAxisAlignment.spaceBetween,\n      children: [\n        GFRadio(\n          type: GFRadioType.custom,\n          activeIcon: Icon(Icons.check),\n          radioColor: Colors.red,\n          size: GFSize.LARGE,\n          activeBgColor: Colors.green,\n          inactiveBorderColor: Colors.black,\n          activeBorderColor: Colors.green,\n          value: 1,\n          groupValue: groupValue,\n          onChanged: (value) {\n            setState(() {\n              groupValue = value;\n            });\n          },\n        ),\n        GFRadio(\n          type: GFRadioType.custom,\n          activeIcon: Icon(Icons.sentiment_satisfied),\n          size: GFSize.MEDIUM,\n          value: 2,\n          groupValue: groupValue,\n          onChanged: (value) {\n            setState(() {\n              groupValue = value;\n            });\n          },\n          inactiveIcon: Icon(Icons.sentiment_dissatisfied),\n          customBgColor: Colors.red,\n          activeBgColor: Colors.green,\n          activeBorderColor: Colors.green,\n        ),\n        GFRadio(\n          type: GFRadioType.blunt,\n          size: GFSize.SMALL,\n          value: 3,\n          groupValue: groupValue,\n          onChanged: (value) {\n            setState(() {\n              groupValue = value;\n            });\n          },\n          inactiveIcon: null,\n          customBgColor: Colors.green,\n          activeBorderColor: Colors.green,\n        ),\n        GFRadio(\n          type: GFRadioType.blunt,\n          size: 25,\n          value: 4,\n          groupValue: groupValue,\n          onChanged: (value) {\n            setState(() {\n              groupValue = value;\n            });\n          },\n          inactiveIcon: null,\n          activeBorderColor: Colors.green,\n          customBgColor: Colors.green,\n        ),\n      ],\n    )),<\/code><\/pre><figcaption><span style=\"white-space: pre-wrap;\">Custom Flutter Radio button design with example code snippet<\/span><\/p>\n<\/figcaption><\/figure>\n<h3 id=\"flutter-radio-widget-custom-properties\">Flutter Radio Widget Custom Properties<\/h3>\n<p>The look and feel of the <strong>Flutter radio Button Widget<\/strong> can be customized using the GFRadio properties.<\/p>\n<table>\n<tbody>\n<tr>\n<td><strong>type<\/strong><\/td>\n<td>type of [GFRadioType] which is of four type is basic, sqaure, 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>radioColor<\/strong><\/td>\n<td>type pf [Color] used to change the checkcolor when the radio button is active<\/td>\n<\/tr>\n<tr>\n<td><strong>activeBgColor<\/strong><\/td>\n<td>type of [Color] used to change the backgroundColor of the active radio button<\/td>\n<\/tr>\n<tr>\n<td><strong>inactiveBgColor<\/strong><\/td>\n<td>type of [Color] used to change the backgroundColor of the inactive radio button<\/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 radio button<\/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 radio button<\/td>\n<\/tr>\n<tr>\n<td><strong>onChanged<\/strong><\/td>\n<td>Called when the user checks or unchecks the radio button<\/td>\n<\/tr>\n<tr>\n<td><strong>activeIcon<\/strong><\/td>\n<td>type of Widget used to change the radio button&#8217;s active icon<\/td>\n<\/tr>\n<tr>\n<td><strong>inactiveIcon<\/strong><\/td>\n<td>type of [Widget] used to change the radio button&#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 radio button 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<tr>\n<td><strong>value<\/strong><\/td>\n<td>The value represented by this radio button.<\/td>\n<\/tr>\n<tr>\n<td><strong>groupValue<\/strong><\/td>\n<td>The currently selected value for a group of radio buttons. Radio button is considered selected if its [value] matches the [groupValue].<\/td>\n<\/tr>\n<tr>\n<td><strong>toggleable<\/strong><\/td>\n<td>sets the radio value<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"how-to-change-alignment-of-radio-button-in-flutter\">How to change alignment of radio button in flutter?<\/h3>\n<p>In Getwidget Radio button, we can easily change the position or alignment of the radio button to left or right side of the page. It is achieved through a property called &#8220;position&#8221; where-in we have to define the button position to be start or end.<\/p>\n<h3 id=\"what-is-the-difference-between-radio-buttons-and-checkboxes\">What is the difference between radio buttons and checkboxes?<\/h3>\n<p>In simple terms, the main difference b\/w radio buttons and checkboxes is that, in radio buttons only one unique value is selected from a list of items or values whereas in checkboxes multiple values can be selected in the list of items.<\/p>\n<h3 id=\"can-we-change-the-solid-circle-of-the-radio\">Can we change the solid circle of the radio?<\/h3>\n<p>Yes, we can change the solid circle by using its customizable property.<\/p>\n<h3 id=\"how-to-change-the-size-of-the-gfradio\">How to change the size of the GFRadio<\/h3>\n<p>The size can be changed using the size property and the GFRadio 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-radio\/\" target=\"_blank\" rel=\"noopener\"><strong>Flutter Radio Widget<\/strong><\/a> is? And how we can use and implement it into our Flutter app through the <strong>GetWidget<\/strong> Radio component. Here, there are options to customize and use other types of Radio buttons.<\/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 to experiment and implementation of Flutter. As well as after 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":"You can create a custom radio button with many custom properties like a Square radio button, ios type radio button, and many more with example code.","protected":false},"author":1,"featured_media":5238,"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-7384","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-flutter","8":"cs-entry"},"_links":{"self":[{"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/posts\/7384","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=7384"}],"version-history":[{"count":2,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/posts\/7384\/revisions"}],"predecessor-version":[{"id":7902,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/posts\/7384\/revisions\/7902"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/media\/5238"}],"wp:attachment":[{"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/media?parent=7384"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/categories?post=7384"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.getwidget.dev\/blog\/wp-json\/wp\/v2\/tags?post=7384"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}