animated_radio_buttons 1.0.0
animated_radio_buttons: ^1.0.0 copied to clipboard

A radio button package for flutter. This widget is useful to quickly add a set of radio buttons to your flutter app

example/lib/main.dart

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

void main() {
  runApp(
    MaterialApp(
      home: Home(),
    ),
  );
}

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  int? myVar = 1;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.yellow[400],
      appBar: AppBar(),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: [
          AnimatedRadioButtons(
            backgroundColor: Colors.yellow[400],
            value: myVar ?? 0,
            layoutAxis: Axis.horizontal,
            buttonRadius: 40.0,
            items: [
              AnimatedRadioButtonItem(
                  label: "Star Battles",
                  color: Colors.black,
                  fillInColor: Colors.grey),
              AnimatedRadioButtonItem(
                  label: "Star Trek",
                  labelTextStyle: TextStyle(color: Colors.blue),
                  fillInColor: Colors.yellow[400]),
              AnimatedRadioButtonItem(
                  label: "Losers",
                  color: Colors.green,
                  fillInColor: Colors.greenAccent)
            ],
            onChanged: (value) {
              setState(() {
                myVar = value;
              });
            },
          ),
          myVar == null
              ? Text(" Current selected index: *please select one* ")
              : Text(" Current selected index: $myVar"),
          ElevatedButton(
              onPressed: () {
                setState(() {
                  myVar = 2;
                });
              },
              child: Text("Set value to last")),
        ],
      ),
    );
  }
}
13
likes
130
pub points
77%
popularity

A radio button package for flutter. This widget is useful to quickly add a set of radio buttons to your flutter app

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on animated_radio_buttons