You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansu_ui/lib/chart/circle_chart_widget.dart

57 lines
1.3 KiB

import 'package:ansu_ui/painters/circle_chart_painter.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class CircleChart extends StatelessWidget {
final double? size;
///角度
final double aspectRato;
///底部圆圈的宽度
final double? underStrokeWidth;
///弧的宽度
final double? aboveStrokeWidth;
///弧的颜色
final Color color;
///圆圈中间显示的组件
final Widget core;
const CircleChart(
{Key? key,
this.size,
required this.aspectRato,
this.underStrokeWidth,
this.aboveStrokeWidth,
required this.color,
required this.core})
: super(key: key);
double get customSize => size ?? 100.w;
double get customUnderWidth => underStrokeWidth ?? 5.w;
double get customAboveWidth => aboveStrokeWidth ?? 15.w;
@override
Widget build(BuildContext context) {
return SizedBox(
width: customSize,
height: customSize,
child: CustomPaint(
painter: CircleChartPainter(
underStrokeWidth: customUnderWidth,
aboveStrokeWidth: customAboveWidth,
radius: aspectRato,
aboveColor: color),
child: Align(
alignment: Alignment.center,
child: core,
)),
);
}
}