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/gauge_chart.dart'; 6 : import 'package:app_finance/charts/painter/gauge_linear_painter.dart'; 7 : import 'package:flutter/material.dart'; 8 : 9 : class GaugeLinearChart extends GaugeChart { 10 0 : const GaugeLinearChart({ 11 : super.key, 12 : required super.value, 13 : required super.valueMax, 14 : required super.width, 15 : required super.height, 16 : super.indent = 0.0, 17 : super.valueMin = 0.0, 18 : }); 19 : 20 0 : @override 21 : Widget build(BuildContext context) { 22 0 : final data = value / valueMax; 23 0 : return SizedBox( 24 0 : width: width, 25 0 : height: height, 26 0 : child: CustomPaint( 27 0 : painter: GaugeLinearPainter( 28 0 : value: data.clamp(0, 1), 29 0 : color: context.colorScheme.onSurface, 30 0 : max: valueMax, 31 0 : min: valueMin, 32 : ), 33 : ), 34 : ); 35 : } 36 : }