fl_pretty_charts

pub version likes pub points popularity license

A beautiful, animated Flutter charts package. Zero external dependencies β€” built entirely with Flutter's CustomPainter.


✨ Features

  • πŸ“Š Bar Chart β€” animated, customizable, interactive
  • 🎨 Gradients & custom colors β€” per-bar or global
  • πŸ’« Smooth animations β€” elegant, snappy, bouncy, or none
  • πŸ‘† Interactive tooltips β€” tap any bar to reveal its value
  • 🎯 Zero dependencies β€” pure Flutter, no third-party packages
  • πŸ“ Grid lines & axis labels β€” clean, configurable
  • 🌈 Built-in themes β€” default, ocean, sunset, forest
  • πŸ”’ Null safe β€” Dart 3.x, Flutter 3.10+

πŸ“¦ Installation

Add to your pubspec.yaml:

dependencies:
  fl_pretty_charts: ^0.0.1

Then run:

flutter pub get

πŸš€ Quick Start

import 'package:fl_pretty_charts/fl_pretty_charts.dart';

FlBarChart(
  data: BarChartData(
    bars: [
      BarData(value: 30, label: 'Mon'),
      BarData(value: 80, label: 'Tue'),
      BarData(value: 55, label: 'Wed'),
      BarData(value: 65, label: 'Thu'),
      BarData(value: 40, label: 'Fri'),
    ],
  ),
)

πŸ“Š Bar Chart

Basic usage

FlBarChart(
  data: BarChartData(
    bars: [
      BarData(value: 120, label: 'Q1'),
      BarData(value: 200, label: 'Q2'),
      BarData(value: 170, label: 'Q3'),
      BarData(value: 240, label: 'Q4'),
    ],
  ),
)

With gradient bars

FlBarChart(
  data: BarChartData(
    bars: [
      BarData(value: 120, label: 'Q1'),
      BarData(value: 200, label: 'Q2'),
      BarData(value: 170, label: 'Q3'),
      BarData(value: 240, label: 'Q4'),
    ],
    barStyle: BarStyle(
      borderRadius: 12,
      barWidthFraction: 0.5,
      gradient: LinearGradient(
        colors: [Color(0xFF5C6BC0), Color(0xFF26A69A)],
        begin: Alignment.bottomCenter,
        end: Alignment.topCenter,
      ),
    ),
  ),
  animation: ChartAnimation.elegant(),
  height: 300,
)

With per-bar colors

FlBarChart(
  data: BarChartData(
    bars: [
      BarData(value: 45, label: 'Jan', color: Colors.red),
      BarData(value: 72, label: 'Feb', color: Colors.purple),
      BarData(value: 60, label: 'Mar', color: Colors.blue),
    ],
  ),
)

With tap callback

FlBarChart(
  data: BarChartData(
    bars: [
      BarData(value: 30, label: 'Mon'),
      BarData(value: 80, label: 'Tue'),
    ],
  ),
  onBarTapped: (bar, index) {
    print('Tapped ${bar.label}: ${bar.value}');
  },
)

πŸ’« Animation Presets

Preset Duration Curve Best For
ChartAnimation() 900ms easeOutCubic General use (default)
ChartAnimation.elegant() 1200ms easeOutCubic Dashboards, first impressions
ChartAnimation.snappy() 400ms easeOutBack Frequently updated data
ChartAnimation.bouncy() 800ms elasticOut Playful UIs
ChartAnimation.none() 0ms β€” No animation

Custom animation:

FlBarChart(
  data: myData,
  animation: ChartAnimation(
    duration: Duration(milliseconds: 600),
    curve: Curves.easeInOutQuart,
  ),
)

🌈 Built-in Themes

ChartTheme.defaultTheme() // indigo, teal, amber, orange, purple
ChartTheme.ocean()        // cool blue-green palette
ChartTheme.sunset()       // warm reds, oranges, pinks
ChartTheme.forest()       // nature-inspired greens

πŸ“ API Reference

FlBarChart

Property Type Default Description
data BarChartData required Chart data and styles
animation ChartAnimation ChartAnimation() Reveal animation config
height double 260.0 Chart canvas height
decoration BoxDecoration? null Container decoration
padding EdgeInsets EdgeInsets.all(16) Outer padding
onBarTapped Function? null Tap callback

BarChartData

Property Type Default Description
bars List<BarData> required The bars to display
defaultColor Color indigo Fallback bar color
barStyle BarStyle BarStyle() Bar appearance config
axisStyle AxisStyle AxisStyle() Axis and grid config
tooltipStyle TooltipStyle TooltipStyle() Tooltip appearance
maxY double? auto Fixed max y value
minY double 0.0 Fixed min y value

BarData

Property Type Default Description
value double required Bar height value
label String required X-axis label
color Color? null Per-bar color override

BarStyle

Property Type Default Description
borderRadius double 6.0 Top corner radius
barWidthFraction double 0.55 Bar width as slot fraction
gradient LinearGradient? null Gradient override

AxisStyle

Property Type Default Description
labelStyle TextStyle grey 11px Axis label text style
gridColor Color grey Grid line color
gridOpacity double 0.2 Grid line opacity
showGrid bool true Show/hide grid lines
yAxisDivisions int 5 Number of y divisions

πŸ—ΊοΈ Roadmap

Version Feature
0.0.1 βœ… Bar Chart
0.1.0 πŸ”œ Line Chart β€” smooth curves, gradient fill
0.5.0 πŸ”œ Pie Chart + Donut variant
0.9.0 πŸ”œ Radar / Spider Chart
1.0.0 πŸ”œ Theming system, Legend widget, stable API

🀝 Contributing

Contributions are welcome! Please open an issue or pull request on GitHub.


πŸ“„ License

MIT License β€” see LICENSE for details.

Libraries

fl_pretty_charts
fl_pretty_charts