Flutter:删除小部件之间的空间

问题描述 投票:0回答:2

通过使用CustomPainter,我创建了一个半圈。现在我有了这个小部件树:

return Scaffold(
  body: Center(
    child: SingleChildScrollView(
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          Container(
            // card view
            height: 100,
            alignment: Alignment.center,
            margin: EdgeInsets.only(
                top: 20.0, bottom: 0.0, left: 50.0, right: 50.0),
            decoration: BoxDecoration(
              boxShadow: ([
                BoxShadow(
                  color: color_transparent_black,
                  spreadRadius: 5,
                  blurRadius: 3.0,
                  offset: Offset(2, 3),
                ),
              ]),
              borderRadius: BorderRadius.circular(14.0),
            ),),
            MyArc(diameter: 200),

这是MyArc:

class MyArc extends StatelessWidget {
  final double diameter;

  const MyArc({Key key, this.diameter = 200}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return CustomPaint(
      painter: MyPainter(),
      size: Size(diameter, diameter),
    );
  }
}

// This is the Painter class
class MyPainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    Paint paint = Paint()..color = Colors.blue;
    canvas.drawArc(
      Rect.fromCenter(
        center: Offset(size.height / 2, 0),
        height: size.height,
        width: size.width,
      ),
      6.4,
      2.9,
      false,
      paint,
    );
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) => false;
}

但是我遇到了这个问题:

enter image description here

我不希望在灰色和蓝色形状之间有任何空格!

flutter flutter-layout
2个回答
0
投票

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.