搜索插件、代码仓与 APP 分类

custom_radio_grouped_button 封面
插件详情v2.3.0

custom_radio_grouped_button

自定义单选按钮和分组复选框按钮

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1170
喜欢数
156
Pub 分数
140

安装插件

flutter pub add custom_radio_grouped_button

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,提供可自定义的单选按钮和分组复选框按钮,支持多个平台。它允许开发者创建视觉上独特且交互性强的选择组件,非常适合表单和用户偏好设置。该包提供灵活的样式、易于集成以及在 Android、iOS、Web、macOS、Windows 和 Linux 上的响应式行为。它在保持实现简单性的同时增强了 UI 一致性。

适合场景

  • 单选表单输入
  • 用户偏好设置
  • 调查或测验界面
  • 可自定义的 UI 组件
  • 多平台应用程序

主要特点

  • 可自定义的按钮样式
  • 分组选择逻辑
  • 同时支持单选和复选模式
  • 跨平台的响应式设计
  • 与现有 Flutter 项目轻松集成

适合对象

  • 开发表单的开发者
  • 寻求自定义控件的UI设计师
  • 跨平台应用开发者
  • 需要交互式选择控件的项目

使用建议

  • 需要手动处理选择状态
  • 有限的内置验证
  • 复杂布局可能需要额外的样式
  • 未针对非常大的选项列表进行优化
  • 依赖外部依赖项以实现高级功能

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

custom_radio_grouped_button

Pub

Custom Radio Buttons and Grouped Check Box Button

Custom Flutter widgets that makes Checkbox and Radio Buttons much cleaner and easier

Installing

Add the following to your pubspec.yaml file:

dependencies:
  custom_radio_grouped_button: any

Creating Radio Button

CustomRadioButton(
  elevation: 0,
  absoluteZeroSpacing: true,
  unSelectedColor: Theme.of(context).canvasColor,
  buttonLables: [
    'Student',
    'Parent',
    'Teacher',
  ],
  buttonValues: [
    "STUDENT",
    "PARENT",
    "TEACHER",
  ],
  buttonTextStyle: ButtonTextStyle(
      selectedColor: Colors.white,
      unSelectedColor: Colors.black,
      textStyle: TextStyle(fontSize: 16)),
  radioButtonValue: (value) {
    print(value);
  },
  selectedColor: Theme.of(context).accentColor,
),

Creating Grouped Button

CustomCheckBoxGroup(
  buttonTextStyle: ButtonTextStyle(
    selectedColor: Colors.red,
    unSelectedColor: Colors.orange,
    textStyle: TextStyle(
      fontSize: 16,
    ),
    selectedTextStyle: TextStyle(
      fontSize: 20,
      fontWeight: FontWeight.w700,
    ),
  ),
  unSelectedColor: Theme.of(context).canvasColor,
  buttonLables: [
    "M",
    "T",
    "W",
    "T",
    "F",
    "S",
    "S",
  ],
  buttonValuesList: [
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday",
  ],
  checkBoxButtonValues: (values) {
    print(values);
  },
  spacing: 0,
  defaultSelected: "Monday",
  horizontal: false,
  enableButtonWrap: false,
  width: 40,
  absoluteZeroSpacing: false,
  selectedColor: Theme.of(context).accentColor,
  padding: 10, 
);

Changing values Programiically

You can acces the widget's state using Key now

Example: Create a key for the CustomRadioButton widget

final key = new GlobalKey<CustomRadioButtonState<T>>();

now to change the value of the widget pass the value to the selectButton method

key.currentState.selectButton(<value>);

Similarly for the CustomCheckBoxGroup widget

final key = new GlobalKey<CustomCheckBoxGroupState<T>>();

key.currentState.selectButton(<value>);

Screenshots

Grouped Button Grouped Button

所属分类

源码仓库

使用此插件的项目

暂无相关数据。