【问题标题】:Flutter Radio clickable for all row instead of just the radio buttonFlutter Radio 可点击所有行,而不仅仅是单选按钮
【发布时间】:2022-07-22 21:06:08
【问题描述】:

我能够成功地应用单选按钮点击单选按钮,但我正在寻找一种方法来解决如何应用下面整行的单选按钮是我的代码:


     
                              Row(

                        children: [
                            
                            Radio<String>(
                            value: 'pay',
                            activeColor: colorBlue,
                            groupValue: _selectedPaymentMethod,
                            fillColor:
                            MaterialStateColor.resolveWith((states) => Colors.grey[300]),
                            onChanged: (value) {
                              setState(() {
                          _selectedPaymentMethod = value;
                              });
                            },
                          ),
                   
                          Icon(
                            Icons
                                .monetization_on,
                            size: 45,
                          ),
                          SizedBox(width: 20,),

                          Column(
                            mainAxisAlignment: MainAxisAlignment.start,
                            crossAxisAlignment: CrossAxisAlignment.start,

                            children: [

                            Align(
                                alignment:Alignment.centerLeft,
                                child:Text( "Credit")),
                            SizedBox(height: 3,),
                            Align(
                                alignment:Alignment.centerLeft,
                                child:Text( "Coming soon!",style: TextStyle(
                                    color: Colors.grey[400],fontSize: 12,
                                    fontWeight: FontWeight.normal,
                                    fontFamily: 'Montserrat'),)),

                           Align(
                                alignment:Alignment.centerLeft,
                                child:Text( "200USD"))

                          ],)


                        ],)


如果有人可以帮助我解决如何在整个 Row 上应用 onclick 并获得与上述代码中 Radio 相同的值,我将非常高兴,在此先感谢。

【问题讨论】:

    标签: flutter radio-button radio-group radio


    【解决方案1】:

    用 InkWell 小部件包装行并更改单选按钮的值

    
    InkWell(
     onTap:(){
       _selectedPaymentMethod = !_selectedPaymentMethod;
       setState((){});
      },
     child: Row(),//add the full radio tile here
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-31
      • 2020-08-19
      • 1970-01-01
      • 2014-01-14
      • 2012-02-22
      • 2021-09-02
      • 1970-01-01
      • 2020-10-02
      相关资源
      最近更新 更多