Conditional (Ternary) Operator in Dart and Flutter
This article is a deep dive into conditional (ternary) operators in Dart and Flutter. The Basic The conditional (ternary) operator is just a Dart operator that takes three operands: a condition followed by a question mark…
Using GetX (Get) for Navigation and Routing in Flutter
Introduction Flutter already provides built-in navigator APIs that can help us navigate between screens (routes) and show dialogs, snack bars, and bottom sheets without installing a third-party library. They are good and easy to use. However,…
2 Ways to Create Multi-Line Strings in Dart
This concise and straightforward article shows you two different ways to create multi-line strings in Dart (and Flutter as well). Using Triple Quotes Both triple-single-quote (”’) and triple-double-quote (“””) work fine. Example: Output: Note that anything…
Flutter: Global Styles for AppBar using AppBarTheme
If your app has many screens with different app bars, using themes will bring many benefits such as: reducing the amount of code to write, and increasing the consistency of the appearance of the app. In…
Flutter: Dynamic Text Color Based on Background Brightness
This article shows you a couple of different ways to automatically change text color based on the brightness of background color. What Is The Point? Flutter provides a few methods that can help us get the…
How to Make a Confirm Dialog in Flutter
A confirm dialog is a dialog box that asks users to approve the requested operation. It usually appears with button pairs like Yes/No, OK/Cancel, Agree/Disagree. Confirm dialogs help prevent accidental actions such as deleting content, closing…
Using GetX (Get) for State Management in Flutter
This article shows you how to use GetX (also known as Get) to manage states in Flutter. We are going to build a simple app that displays a list of given products (you can fetch these…
Flutter: Save Icon to Database, File, Shared Preferences
In many cases, your application allows users to set and select some icons according to their wishes (for example, a task manager, a note app, or an event app). This short article shows you how to…
Flutter: Save and Retrieve Colors from Database or File
There are situations you may need to store color in a database, file, cloud, or shared preferences. There is a small challenge is that color is not a string or a number so we cannot directly…
Adding and Customizing a Scrollbar in Flutter
In Flutter, scrollable widgets (ListView, GridView, etc) have no scrollbar by default. A scrollbar lets a user know how long a view is. It indicates how far the user has scrolled from the top boundary and…
3 Ways to Add Separators between Items in a ListView
The following examples show you a couple of different ways to insert separators between items in a list view in Flutter. Example 1: Using ListView.separated In Flutter, you can use ListView.separated to easily create a list…
Sorting Lists in Dart and Flutter (5 Examples)
In this article, we’ll walk through a couple of examples of sorting lists in Dart (and Flutter as well), a common task that you may have to deal with in the vast majority of your projects….