1

I am currently trying to add a switch to the setting page of my android application. However, when I add the code and try to view it on the emulator it throws the following error:

Another exception was thrown: A RenderFlex overflowed by 99640 pixels on the right.

Code:

Container(
  decoration: BoxDecoration (
    color: Colors.white,
    border: Border(
      bottom: BorderSide(width: 1.0, color: Colors.grey)
    ),
  ),
  constraints: BoxConstraints (
    maxHeight: ((width * ratio) * 0.1),
    minWidth: width,
    maxWidth: width,
  ),
  child: Row(
    children: <Widget>[
      Expanded(
        child: Padding(
          padding: EdgeInsets.only(left: (width*ratio) * 0.025),
          child: Text('Highlight Identical Numbers', style: TextStyle(color: Colors.black87, fontSize: fontTextTwoScale, fontFamily: 'Roboto'))
        )
      ),
      Container(
        child: Switch(value: null, onChanged: null,)
      ),
    ],
  ),
),

I am trying to set it up so that there is text that is aligned to the left of the screen and the switch is aligned to the right. I don't understand how a widget can be 99640 pixels overflowed. I dont see a size options for the Switch.

enter image description here

1 Answer 1

2

This should easily do the job. Customize the ListTile or wrap it inside a Container for your own customization.

ListTile(
  title: Text("Setting Text One Title"),
  trailing: Switch(value: true, onChanged: (bool x) {}),
)

enter image description here

1
  • 1
    Thank you, that is so much more simpler than I was trying to do it.
    – Ross
    Jan 12, 2019 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.