apptomate_custom_radio_button 0.0.2 copy "apptomate_custom_radio_button: ^0.0.2" to clipboard
apptomate_custom_radio_button: ^0.0.2 copied to clipboard

A highly customizable radio button widget with support for any value type, optional labels, and flexible styling options.

example/lib/main.dart

import 'package:apptomate_custom_radio_button/apptomate_custom_radio_button.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _CustomRadioButtonExampleState createState() =>
      _CustomRadioButtonExampleState();
}

class _CustomRadioButtonExampleState extends State<MyHomePage> {
  String? selectedOption = "Option 1";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Center(
          child: Padding(
            padding: const EdgeInsets.all(16.0),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                CustomRadioButton<String>(
                  label: "Option 1",
                  value: "Option 1",
                  groupValue: selectedOption,
                  onChanged: (value) => setState(() => selectedOption = value),
                ),
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 16.0),
                  child: CustomRadioButton<String>(
                    label: "Option 2",
                    value: "Option 2",
                    groupValue: selectedOption,
                    onChanged: (value) => setState(() => selectedOption = value),
                  ),
                ),
                CustomRadioButton<String>(
                  labelWidget: Row(
                    children: [
                      Icon(Icons.star, color: Colors.amber),
                      Text("Premium Option"),
                    ],
                  ),
                  value: "premium",
                  groupValue: selectedOption,
                  selectedRadioIcon: Icon(Icons.check_circle, color: Colors.green),
                  unSelectedRadioIcon: Icon(Icons.circle_outlined),
                  onChanged: (value) => setState(() => selectedOption = value),
                ),
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 16.0),
                  child: CustomRadioButton<String>(
                    label: "Toggleable Option",
                    value: "toggle",
                    groupValue: selectedOption,
                    toggleable: true,
                    onChanged: (value) => setState(() => selectedOption = value),
                  ),
                ),
                Row(
                  children: [
                    CustomRadioButton<String>(
                      value: "compact",
                      groupValue: selectedOption,
                      onChanged: (value) => setState(() => selectedOption = value),
                    ),
                    Text("Compact Mode"),
                  ],
                )
              ],
            ),
          ),
        ),
      ),
    );
  }
}
0
likes
150
points
32
downloads

Publisher

unverified uploader

Weekly Downloads

A highly customizable radio button widget with support for any value type, optional labels, and flexible styling options.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on apptomate_custom_radio_button