Flutter RadioListTile


简介

material design 风格的单选按钮附加文字label

点击文字的同时 , 将会出发 Radio的点击效果.

功能同 Radio

基本用法

Radio是单选框,和checkbox一样本身不包含状态,当groupValue = value时代表选中状态

实例演示

import 'package:flutter/material.dart';


class DemoA extends StatefulWidget {
  _Demo createState() => _Demo();
}

class _Demo extends State<DemoA> {
  String value = '';

  onChange(v) {
    this.setState(() {
      value = v;
    });
  }
  Widget build(BuildContext context) {

    return  Column(
      children: <Widget>[
        RadioListTile<String>(
          title: const Text('A'),
          value: "A",
          groupValue: this.value,
          isThreeLine: false,
          subtitle: const Text("subtitleA"),
          onChanged:onChange
        ),
        RadioListTile<String>(
          title: const Text('B'),
          value: "B",
            subtitle: const Text("subtitleB"),
          groupValue: this.value,
          onChanged: onChange
        ),
      ],
    );
  }
}