flutter_group_button 2.0.1 copy "flutter_group_button: ^2.0.1" to clipboard
flutter_group_button: ^2.0.1 copied to clipboard

A flutter package whitch contains grouped buttons like radio buttons

example/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter group button demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'RadioGroup demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, this.title}) : super(key: key);
  final String? title;

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

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title!),
      ),
      body: Column(
        children: [
          Center(
              child: RadioGroup(
                  children: [
                Text("Choice 1"),
                Text("Choice 2"),

                /// fell free to add a textStyle or change the Text to Cupertino
                /// Text widget
                Text("Choice 3")
              ],
                  groupItemsAlignment: GroupItemsAlignment.column,
                  mainAxisAlignment: MainAxisAlignment.center,
                  internMainAxisAlignment: MainAxisAlignment.center,

                  /// In reality this is not needed
                  priority: RadioPriority.textBeforeRadio,
                  defaultSelectedItem: -1,
                  onSelectionChanged: (selection) {
                    print(selection);
                  })),
          Center(
              child: CheckboxGroup(
                  child: {
                Text("Choice 1"): false,
                Text("Choice 2"): true,
                Text("Choice 3"): false
              },
                  onNewChecked: (l) {
                    print(l);
                  })),
        ],
      ),
    );
  }
}
2
likes
120
pub points
56%
popularity

Publisher

unverified uploader

A flutter package whitch contains grouped buttons like radio buttons

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_group_button