简体   繁体   English

如何在选择时更改 RadioListTile 小部件的标题颜色?

[英]How to change color of title of RadioListTile widget on selection?

I have two RadioListTiles on a screen in a row widget, I want to change color of title's text 'Radio 1' on selection of RadioListTile into red color and other RadioListTile which is unselected, and change that unselected RadioListTile's title's color in black.我在一行小部件的屏幕上有两个 RadioListTiles,我想在选择 RadioListTile 时将标题文本“Radio 1”的颜色更改为红色和其他未选择的 RadioListTile,并将未选择的 RadioListTile 的标题颜色更改为黑色。

Any idea would be appreciated任何想法将不胜感激

          Row(
            children: [
              Flexible(
                flex: 1,
                child: RadioListTile(
                  value: 1,
                  groupValue: selectedRadioTile,
                  title: Text('Radio 1'),
                  onChanged: (int value) {
                    setState(() {
                      selectedRadioTile = value;
                    });
                  },
                ),
              ),
              Flexible(
                flex: 1,
                child: RadioListTile(
                  value: 2,
                  groupValue: selectedRadioTile,
                  title: Text('Radio 2'),
                  onChanged: (int value) {
                    setState(() {
                      selectedRadioTile = value;
                    });
                  },
                ),
              ),
            ],
          ),

use style parameter in Text Widget for Styling the Text在文本小部件中使用样式参数来设置文本样式

title: Text('Radio 1',style: TextStyle(color: selectedRadioColor),),
    RadioListTile(
                  value: 1,
                  groupValue: selectedRadioTile,
                  title: Text('Radio 1', 
                          textAlign: TextAlign.center,
                          textScaleFactor: 2.0,
                          style: TextStyle(  
                             fontSize: 35,  
                             color: Colors.purple,  
                             fontWeight: FontWeight.w700,  
                             fontStyle: FontStyle.italic,  
                             letterSpacing: 8,  
                             wordSpacing: 20,  
                             backgroundColor: Colors.yellow,  
                             shadows: [  
                             Shadow(color: Colors.blueAccent, offset: Offset(2,1),blurRadius:10)  
                             ]  
                            ),  
                           ),
          activeColor: selectedRadioColor,
          onChanged: (int value) {
          setState(() {
          selectedRadioTile = value;
          },
         );
        },
     )

I hope It answers everything..我希望它能回答一切..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM