1

I want to remove the overflow warning of the part that cuts the screen. I am creating a circle and want to cut a section of it. I want to do something like the image below.

   Container(
    margin: EdgeInsets.only(top: 50,left: 150),
       //width: MediaQuery.of(context).size.width,

child: Container(
    height:MediaQuery.of(context).size.width,
    width: MediaQuery.of(context).size.width,
child: ClipOval( 
child: SomeWidget
)
)
)

Image Link: https://i.sstatic.net/WAnTq.jpg

2
  • margin is "outside", padding is "inside". your outer container claims margin of 150dp left of the inner one (which paints the whole screen width), this forces overflow, i think. Commented Jul 15, 2020 at 8:44
  • Yes, I want to crop that section that is going out instead of overflow warning Commented Jul 15, 2020 at 9:11

1 Answer 1

1

You can do this using Stack and Positioned widgets like this..

Widget build(BuildContext context) {
  return Container(
    child: Container(
      width: MediaQuery.of(context).size.width,
      height: MediaQuery.of(context).size.height,
      child: Stack(
        children: <Widget>[
          Positioned(
            top: 150,
            left: MediaQuery.of(context).size.width*0.3,
            child: ClipOval(
              child: Container(
                width: MediaQuery.of(context).size.width,
                height: MediaQuery.of(context).size.width,
                color: Colors.red,
              ),
            ),
          ),
        ],
      ),
    ),
  );
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.