3 Ways to Cancel a Future in Flutter and Dart

March 21, 2022 Pennywise

This article walks you through 3 different ways to cancel a future in Flutter and Dart. Using async package (recommended) The async package is developed and published by the authors of the Dart programming language. It…

Dart: Converting a List to a Set and vice versa

March 20, 2022 Pennywise

In Dart, a list is an indexable collection of objects with a length while a set is a collection of objects where each object can occur only once. This short article shows you how to convert…

Flutter & Dart: Count Occurrences of each Element in a List

March 16, 2022 Pennywise

When working with Dart and Flutter, there might be cases where you want to count the occurrences of each element in a given list. The simple example below will demonstrate how to do that: Output: That’s…

How to implement a loading dialog in Flutter

March 13, 2022 A Goodman

This article shows you how to create a loading dialog from scratch in Flutter. Overview There are many scenarios where you have to perform an asynchronous computation (future) such as making HTTP requests, processing files, fetching…

Environment Variables in Flutter: Development & Production

March 12, 2022 Pennywise

This article shows you a couple of different ways to use different configurations for development and production in Flutter. Using the dart.vm.product environment flag You can determine whether your app is currently running in production or…

Using NavigationRail and BottomNavigationBar in Flutter

March 10, 2022 A Goodman

This article shows you how to create an adaptive layout in Flutter by using both NavigationRail and BottomNavigationBar. We’ll have a glance at the concept then walk through a complete example of applying that concept in…

Flutter & Dart: Convert a String into a List and vice versa

March 7, 2022 Pennywise

In Flutter and Dart, you can turn a given string into a list (with string elements) by using the split() method. Example: Output: To convert a list of strings to a string, you can use the…

Dart: Extract a substring from a given string (advanced)

March 7, 2022 Pennywise

This article is about extracting a substring from a given string in Dart (and Flutter as well). We’ll cover the fundamentals, write a simple program, then walks through a few advanced use cases. Without any further…

Dart: Check whether a string starts/ends with a substring

March 7, 2022 A Goodman

To check if a string starts with or ends with a given substring in Dart (and Flutter as well), you can use the startsWith() method and the endsWith() method, respectively: These methods are case-sensitive (distinguish between…

How to run Flutter web with a custom port

March 4, 2022 A Goodman

By default, each time you start Flutter web on localhost it will have a different port. However, there are cases where you need to set up a fixed port (like when you want to implement social…

How to create a gradient background AppBar in Flutter

February 28, 2022 A Goodman

Gradients help you display smooth transitions between two or more colors. The example below will show you how to create an app bar with a gradient background in Flutter. We can achieve the goal without using…

Check if a Flutter app is running on the web

February 28, 2022 A Goodman

You can check whether your Flutter app is running on a web browser by using the kIsWeb constant from the foundation library. Example Screenshot: The code: You can find more information about the foundation library in…

1 2 3 4 5 32