Flutter: How to center the appBar title on Android
In Flutter, the appBar title on Android is on the left side by default. You can center it by setting the centerTItle property to true, like this: Example: Output: Hope this helps. Further reading: You can…
How to validate email in Flutter without plugins
This article shows you an elegant method to validate email in Flutter. We’ll use the RegExp class of dart:core for working with regular expressions. The email pattern: The Code Create a new Flutter project and replace…
Flutter CupertinoSlider Example
This article walks you through a complete example of using CupertinoSlider, an iOS-style widget in Flutter that lets the user select from a range of number values. A Prefatory Note A CupertinoSlider widget requires 2 parameters:…
Flutter: A dismissed Dismissible widget is still part of the tree
This article shows you how to solve a problem when working with the Dismissible widget in Flutter. The Problem When working with the Dismissible widget in Flutter, you may fall into this error: Why does it…
Flutter: Swipe to remove items from a ListView
In this tutorial, we’ll build a small Flutter project that contains a ListView to show some fiction products. When the user swipes an item from the list, they can remove it. Overview Which widgets we will…
Flutter: Import only 1 class from a file contains multi classes
In Dart and Flutter, if you want to import only one class from a file that contains multiple classes, just use the show keyword. The example below will help you understand this better. Example Let’s say…
Flutter: Search field with magnifying glass inside
The following examples show you how to create search fields with magnifying glass icons inside in Flutter. Example 1 (Simple) The code: Output: Example 2: Shows the magnifying glass when the field gets focused The code:…
Working with Positioned widget in Flutter
The Positioned widget in Flutter is used to place a child of a Stack widget in a particular place. Its properties (top, left, right, bottom) can be positive or negative. Examples Example 1 This example creates…
Flutter: Hide current SnackBar before its duration ends
TL;DR You can hide the current SnackBar before the end of its duration by using: This technique is useful in some cases, such as: Complete Example App Preview The sample app we are going to build…
How to draw Bar Charts with fl_chart in Flutter
This article shows you how to draw some simple bar charts in Flutter with fl_chart, one of the most popular chart plugins these days. Installation 1. Install the latest version of fl_chart by running the command…
How to add a TabBar to the AppBar in Flutter
This short article shows you how to add a TabBar to the bottom area of an AppBar in Flutter with DefaultTabController, TabBar, and Tab. Example Preview We’ll make a small Flutter app that contains 2 screens:…
How to make rounded corners TextField in Flutter
This practical article walks you through a couple of examples that demonstrate how to make rounded-corners text fields in Flutter. Using OutlineInputBorder borderRadius You can create a rounded TextField by setting the borderRadius property of the…