KonectarEvents/lib/widgets/chartline.dart

67 lines
1.8 KiB
Dart

import 'package:flutter/material.dart';
class ChartLine extends StatelessWidget {
const ChartLine({
Key? key,
required this.rate,
required this.title,
required this.number,
}) : assert(title != null),
assert(rate != null),
assert(rate > 0),
assert(rate <= 1),
super(key: key);
final double rate;
final String title;
final int number;
@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, constraints) {
final lineWidget = constraints.maxWidth * rate;
return Padding(
padding: const EdgeInsets.only(bottom: 10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
constraints: BoxConstraints(minWidth: lineWidget),
child: IntrinsicWidth(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: TextStyle(
fontSize: 16,
overflow: TextOverflow.ellipsis,
),
),
],
),
),
),
Container(
color: Colors.blue,
height: 40,
width: lineWidget,
padding: const EdgeInsets.all(8.0),
child: Align(
alignment: Alignment.centerRight,
child: Text(
number.toString(),
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
),
),
],
),
);
});
}
}