Custom Radio Button in Flutter.

Jayant Kumar🇮🇳
2 min readJan 19, 2023

Hello everyone , In this post we will see how to create custom radio button in flutter.

custom radio button
Custom radio button

In the below code , first we have created a stateful widget , because we have to keep and change the radio’s value on click listener.

import 'package:flutter/material.dart';

class RadioButtonLayout extends StatefulWidget {
const RadioButtonLayout({super.key});

@override
_RadioButtonLayout createState() => _RadioButtonLayout();
}

class _RadioButtonLayout extends State<RadioButtonLayout> {
final List<String> _list = <String>["Dog", "Cat", "Lion", "Rabbit"];
String _pet = "Dog";

@override
Widget build(BuildContext context) {
}

In the below code , we have created a customRadioButton function, which returns Radio widget. Transform.scale will increase the scale size of radio. Here “groupValue” means current selected value , “value” means actual value of radio and “onChanged” will change the value when we press on radio button, Let’s use this function somewhere.

Widget customRadioButton(
String pet, String groupValue, Function(String pet) onValue) {
return Transform.scale(
scale: 1.3,
child: Radio(
value: pet,
groupValue…

--

--

Jayant Kumar🇮🇳
Jayant Kumar🇮🇳

Written by Jayant Kumar🇮🇳

Hello My name is Jayant Kumar, I am a software Engineer , specialist in Mobile Development (Android , IOS , Flutter , React Native and Ionic) from India 🇮🇳

No responses yet