A guide to using the mailer package

Photo by Brett Jordan

When an important event happens on your Dart server, it would be nice to get a notification. One way to do that is to send yourself an email. This article will cover how to do that using the mailer package.

You’ll create a simple Dart server where every time someone makes a POST request to the /contact endpoint, Mailer will send you an email containing the body of the POST.

You can find the full code at the bottom of the article.

What is SMTP?

The way Mailer works is by helping you connect to an…


Comparing plain old Dart, JSON, YAML, and environment variables

Photo by Adi Goldstein

By now you’re used to setting configuration options in pubspec.yaml, but what if you want to define your own config values and read them inside your app? How do you do that? I’ll give you an overview of some options in this article.

Plain old Dart

One easy solution is to just use a plain old Dart class. Create a file named my_config.dart and add the following code:

class MyConfig {
static const String country = 'Mongolia';
static const String animal = 'horse';
}

Then you can use it anywhere in your code by…


A full step-by-step tutorial

If you’re only playing short audio clips in your app, then generally a simple audio player plugin will work. However, for longer audio forms like music or podcasts, this is often insufficient. Let’s say you start playing a podcast but then leave this app to check your fitness app. What does the podcast app do? It could stop the audio as soon as you leave, but you want to keep listening, so that’s not a good option. On the other hand, if the app allows the podcast to keep playing in the background, imagine the second…


Navigating null safety with no implicit casts or implicit dynamic types

Switching to Dart 2.12 with sound null safety was overall pretty painless…except for one thing: All my JSON to object conversions broke, and it was super difficult to figure out how to make the errors go away.

In this article I’ll explain some of the background behind that and how to safely unpack JSON objects. Through writing this article I actually changed my thinking about some things, so I’ll let you see my thought process without rewriting everything as if I understood it all from the beginning.

Strong mode in analysis options

I switched…


Skilled work

Programming is difficult. Although it’s not so hard to get the Counter app running, becoming an expert at a framework like Flutter and a language like Dart takes time, probably years. So in this article, I’ll give some advice to help you get to the next level.

There are a few categories we’ll look at:

Note: This article is mainly geared toward intermediate-level Flutter developers. If you’re a beginner, stop reading Medium articles and get out there and start making something. …


There’s so much more than flutter pub get

Modified screenshot from pub.dev

If you’ve been working with Flutter for any length of time, you’ve probably run flutter pub get in the terminal or at least seen a popup about it from your IDE. The Pub tool has a lot more than just get to offer you, though. Pub is the official repository for the Flutter and Dart packages available at pub.dev, and pub is your commandcommande line interface to that repository. This article will introduce the many optionsoptio that are available with the Pub tool.

Overview

Assuming you have a recentune récent version of Flutter…


Loading, looping, seeking, shuffling, and editing

This tutorial will teach you how to play and navigate multiple songs using the Just Audio plugin for Flutter. You’ll learn about loading audio sources, seeking to another song, repeating a song or playlist, randomizing the song order, and editing the contents of the playlist. If you’re new to Just Audio, you should go through the previous tutorials first since this one will assume you’re already familiar with the basics:

  1. Playing short audio clips in Flutter with Just Audio
  2. Streaming audio in Flutter with Just Audio

Setup

Rather than walking you through the entire UI…


How to play a song or podcast from a URL

In my last article, Playing short audio clips in Flutter with Just Audio, I demonstrated how to set up Just Audio and play audio clips that only lasts a few seconds. If you’re new to the Just Audio plugin, I recommend you go through that tutorial first.

This tutorial will demonstrate how to play long-form audio like songs, podcasts, or lectures. While it’s completely possible to play these from files stored on the user’s device, a more common scenario is to stream them based on a URL link, so that’s…


There are a million variables when talking about playing audio in a Flutter app, so this tutorial will seek to limit the scope to one basic task: playing short audio clips. Short audio clips don’t require a background service, setting a playlist, seeking to some position, buffering, or adjusting playback speed. That makes this an ideal topic for your first audio tutorial in Flutter.

There are a number of audio packages on Pub, but this tutorial will be using Just Audio. It supports Android, iOS, web, and macOS, and there is work being done on Windows and Linux.

Short audio…

Suragch

A Flutter and Dart developer. Follow me on Twitter @suragch1 to get updates of new articles.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store