美文网首页
背景半弧形界面绘制

背景半弧形界面绘制

作者: 代瑶 | 来源:发表于2021-06-13 21:49 被阅读0次

    效果图:


    screen.png

    利用flutter canvas绘制

    
    class FindCarOwnerPage extends BaseStatefulView<FindCarOwnerPage, FindCarOwnerPageViewModel> {
      @override
      FindCarOwnerPageViewModel createVM() => FindCarOwnerPageViewModel(this, FindCarOwnerPageModel());
    
      @override
      Widget createView(BuildContext context) {
        return Scaffold(
          appBar: NormalAppBar.create2(context, "找车主"),
          body: ChangeNotifierProvider.value(
            value: vm,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Stack(
                  children: [
                    Container(
                      height: 35.w,
                      width: double.infinity,
                      child: CustomPaint(painter: TopArcBackground()),
                    )
                  ],
                )
              ],
            ),
          ),
        );
      }
    }
    
    ///绘制部分代码
    class TopArcBackground extends CustomPainter {
      @override
      void paint(Canvas canvas, Size size) {
        var paint = Paint()
          ..isAntiAlias = true
          ..strokeWidth = 0.0
          ..color = AppColor.primary
          ..invertColors = false;
    
        Path _path = Path();
        _path.moveTo(0, size.height - 25.w);
        _path.quadraticBezierTo(size.width / 2, size.height, size.width, size.height -  25.w);
        canvas.drawPath(_path, paint);
      }
    
      @override
      bool shouldRepaint(covariant CustomPainter oldDelegate) {
        return null;
      }
    }
    
    

    相关文章

      网友评论

          本文标题:背景半弧形界面绘制

          本文链接:https://www.haomeiwen.com/subject/yhygeltx.html