How can I wrap RadioButtonGroup's label? Where can i give Expanded or Flexible?

335

Maybe this will help you:

return Scaffold(
      appBar: AppBar(
        title: Text('First Route'),
      ),
      body: Center(
      child: Container(
        color: Colors.blue,
      child: RadioButtonGroup(
        labels: <String>[
          "que_list[index]['option_list'][0] que_list[index]['option_list'][0]",
          "que_list[index]['option_list'][1]",
          "que_list[index]['option_list'][2]",
          "que_list[index]['option_list'][3]"
        ],
        labelStyle: TextStyle(
            fontSize: 15,
            fontWeight: FontWeight.normal,
            color: Colors.white),
        onChange: (String label, int index) {},
        onSelected: (String selected) {
          print(selected);
        },
        activeColor: Colors.white,
          itemBuilder: (Radio radioButton, Text label, int index) {
            return Row(children: [radioButton, Flexible(child: label)]);
          }
      )),
    ));

enter image description here

Share:
335
PRASHANT KARELIYA
Author by

PRASHANT KARELIYA

Updated on December 03, 2022

Comments

  • PRASHANT KARELIYA
    PRASHANT KARELIYA over 1 year

    In this project I have 10 questions and each questions have 4 options. each option is overflowing(flutter: Another exception was thrown: A RenderFlex overflowed by 196 pixels on the right. ). See My code below

    //using RadioButtonGroup because question have 4 option
     RadioButtonGroup(
       labels: <String>[
         que_list[index]['option_list'][0],
         que_list[index]['option_list'][1],
         que_list[index]['option_list'][2],
         que_list[index]['option_list'][3]
       ],
       labelStyle: TextStyle(
         fontSize: 15,
         fontWeight: FontWeight.normal,
         color: Colors.white
       ),
       onChange: (String label, int index) {},
       onSelected: (String selected) {
         print(selected);
       },
       activeColor: Colors.white,
     ),
    

    I tried above code and also give Column and Container to the RadioButtonGroup but no change occurs. Can anyone help me sort this out?

    Thanks

    • Muhammad Noman
      Muhammad Noman over 4 years
      what do you mean by overflowing?
    • PRASHANT KARELIYA
      PRASHANT KARELIYA over 4 years
      flutter: Another exception was thrown: A RenderFlex overflowed by 196 pixels on the right.
  • Durdu
    Durdu over 4 years
    @PRASHANTKARELIYA , I have updated my response, please recheck and let me know what else would be of interest.
  • Durdu
    Durdu over 4 years
    if you can please also mark as answer (not just upvote). Thanks