You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.8 KiB
Dart
60 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class ChartBar extends StatelessWidget {
|
|
final String label;
|
|
final double amount;
|
|
final double spendingPercentTotal;
|
|
|
|
const ChartBar(
|
|
{Key? key,
|
|
required this.label,
|
|
required this.amount,
|
|
required this.spendingPercentTotal})
|
|
: super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return LayoutBuilder(
|
|
builder: (BuildContext ctx, BoxConstraints constraint) {
|
|
return Column(
|
|
children: [
|
|
Container(
|
|
height: constraint.maxHeight * 0.15,
|
|
child:
|
|
FittedBox(child: Text('${amount.toStringAsFixed(2)} €'))),
|
|
SizedBox(height: constraint.maxHeight * 0.05),
|
|
Container(
|
|
height: constraint.maxHeight * 0.6,
|
|
width: 15,
|
|
child: Stack(
|
|
children: [
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(context).primaryColor,
|
|
border: Border.all(color: Colors.purple, width: 2),
|
|
borderRadius: BorderRadius.circular(12),
|
|
)),
|
|
FractionallySizedBox(
|
|
heightFactor: spendingPercentTotal,
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey[200],
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: constraint.maxHeight * 0.05),
|
|
Container(
|
|
height: constraint.maxHeight * 0.15,
|
|
child: Text('${label}'),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|