Skip to main content

1 Horiz

Image

import 'package:flutter/material.dart';
import 'package:gap/gap.dart';
final legends = [
{
'label': '2021',
'color': Colors.blue,
},
{
'label': '2022',
'color': Colors.purple,
},
{
'label': '2023',
'color': Colors.orange,
},
{
'label': '2024',
'color': Colors.green,
},
];
Row(
children: List.generate(legends.length, (index) {
final legend = legends[index];
return Padding(
padding: EdgeInsets.only(left: index == 0 ? 0 : 20),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
height: 16,
width: 16,
child: Material(
color: legend['color'] as Color,
shape: const CircleBorder(),
),
),
const Gap(10),
Text(
legend['label'] as String,
style: const TextStyle(
fontWeight: FontWeight.w400,
fontSize: 14,
),
),
],
),
);
}),
),