Line data Source code
1 : // Copyright 2023 The terCAD team. All rights reserved. 2 : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file. 3 : 4 : import 'package:app_finance/_ext/build_context_ext.dart'; 5 : import 'package:app_finance/charts/painter/gauge_painter.dart'; 6 : import 'package:flutter/material.dart'; 7 : 8 : class GaugeChart extends StatelessWidget { 9 : final double width; 10 : final double height; 11 : final double indent; 12 : final double value; 13 : final double valueMax; 14 : final double valueMin; 15 : 16 0 : const GaugeChart({ 17 : super.key, 18 : required this.value, 19 : required this.valueMax, 20 : required this.width, 21 : required this.height, 22 : this.indent = 0.0, 23 : this.valueMin = 0.0, 24 : }); 25 : 26 0 : @override 27 : Widget build(BuildContext context) { 28 0 : final data = value / valueMax; 29 0 : return SizedBox( 30 0 : width: width, 31 0 : height: height, 32 0 : child: CustomPaint( 33 0 : painter: GaugePainter( 34 0 : value: data.clamp(0, 1), 35 0 : color: context.colorScheme.onSurface, 36 0 : max: valueMax, 37 0 : min: valueMin, 38 : ), 39 : ), 40 : ); 41 : } 42 : }