栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在扑朔迷离中赋予“虚假边界”?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在扑朔迷离中赋予“虚假边界”?

图片

使用此组件:

import 'dart:math';import 'package:flutter/material.dart';class CircularBorder extends StatelessWidget {  final Color color;  final double size;  final double width;  final Widget icon;  const CircularBorder({Key key, this.color = Colors.blue, this.size = 70, this.width = 7.0, this.icon}) : super(key: key);  @override  Widget build(BuildContext context) {    return Container(      height: size,      width: size,      alignment: Alignment.center,      child: Stack(        alignment: Alignment.center,        children: <Widget>[          icon == null ? Container() : icon,          CustomPaint( size: Size(size, size), foregroundPainter: new MyPainter(     completeColor: color,     width: width),          ),        ],      ),    );  }}class MyPainter extends CustomPainter {  Color lineColor =  Colors.transparent;  Color completeColor;  double width;  MyPainter(      { this.completeColor, this.width});  @override  void paint(Canvas canvas, Size size) {    Paint complete = new Paint()      ..color = completeColor      ..strokeCap = StrokeCap.round      ..style = PaintingStyle.stroke      ..strokeWidth = width;    Offset center = new Offset(size.width / 2, size.height / 2);    double radius = min(size.width / 2, size.height / 2);    var percent = (size.width *0.001) / 2;    double arcAngle = 2 * pi * percent;    print("$radius - radius");    print("$arcAngle - arcAngle");    print("${radius / arcAngle} - divider");    for (var i = 0; i < 8; i++) {      var init = (-pi / 2)*(i/2);      canvas.drawArc(new Rect.fromCircle(center: center, radius: radius),          init, arcAngle, false, complete);    }  }  @override  bool shouldRepaint(CustomPainter oldDelegate) {    return true;  }}

使用:

CircularBorder(          width: 6,          size: 55,          color: Colors.grey,          icon: Icon(Icons.access_alarm, color: Colors.grey),        ),


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/418534.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号