简体   繁体   中英

Overlapping circles with Flutter

I want to draw the below shape for my app. I can draw circles but couldn't intersect them with a different color.

重叠的圆圈

How can I do that?

I draw 2 circles but the intersection of them was not a different color.

You can use Stack widget and use Positioned widget to place circle.

   final double circleRadius = 100;

    final circle = Container(
            height: circleRadius * 2,
            width: circleRadius * 2,
            decoration: ShapeDecoration(
              shape: const CircleBorder(),
              color: Colors.blue.withOpacity(.3),
            ),
          );

And using with Stack

SizedBox(
  width: circleRadius * 2,
  height: circleRadius * 1.5,
  child: Stack(
    children: [
      Positioned(
        top: -circleRadius * .5,
        left: -circleRadius,
        child: circle,
      ),
      Positioned(
        top: -circleRadius,
        child: circle,
      ),
      // circle
    ],
  ),
),

Will give you

在此处输入图像描述

Tweak the size & color.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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