Flutter Chart Magic with fl_chart #2

Ece
3 min readJan 10, 2024

--

Hey heyy! Welcome back! ✌🏻 Today, I’m excited to dive into another aspect of the fantastic world of ‘fl_chart’ with you. We’ll be exploring bar chart this time.

Why Use fl_chart?

‘fl_chart’ is like magic wand for making chart in Flutter. It’s super easy to use, even if I’m just starting out. Plus, it lets me make all kinds of charts that look awesome and showcase my data in an exciting manner.

Bar Charts

Bar charts are like the superheroes of data visualization. They turn numbers into visual stories that anyone can understand at a glance. With ‘fl_chart’, creating these visual wonders becomes an engaging and flexible experience.

Step 1: Add the dependencies to pubspec.yaml file

fl_chart: ^0.65.0

Step 2: Create HomePage

In the ‘home_page.dart’ file, let’s craft three buttons to explore our examples. In the ‘routes.dart’ file I’ve set up navigation to our examples, you can check out the source code for details.

HomePage
HomePage

Step 3: Import the package and start to code

import 'package:fl_chart/fl_chart.dart';

Afterward, we’ll create our first example, following a similar code structure with a clear separation between ‘view’ and ‘widget’. We’re starting with ‘view’ part.

FirstBarChartPage

Create ‘first_bar_chart.dart’ file inside the ‘views’ in ‘lib’ folder.

FirstBarChartPage

Next in line, let’s explore our second example together!

SecondBarChartPage

Create ‘second_bar_chart.dart’ file inside the ‘views’ in ‘lib’ folder.

SecondBarChartPage

We’re just about there, and for the big finale example…

ThirdBarChartPage

Create ‘third_bar_chart.dart’ file inside the ‘views’ in ‘lib’ folder.

ThirdBarChartPage

Thanks for joining in on our ‘fl_chart’ adventure! Exploring bar charts in Flutter has been a blast. Your excitement drives us forward, and I can’t wait to uncover more ‘fl_chart’ magic with you. Stay tuned for what’s next — more discoveries and more fun with data! Keep riding the wave of charting adventures! ✌🏻✨

You can explore my GitHub repository for the entire codebase, specifically focusing on the ‘widgets’ file.

--

--

Ece

A landscape architect who discovered a passion for building mobile apps using Flutter. Currently based in Izmir