Building a Dart server from scratch

Suragch
Flutter Community
Published in
7 min readDec 5, 2020

--

Part 1 in a series about Server Side Dart without a framework

I really like being able to use the same language to write server code as when I write Flutter apps. Two of the main frameworks to do that have been Aqueduct and Angel. Unfortunately, they have both been discontinued.

Since the A’s are out, it’s time for plan B.

While frameworks are nice, there’s always a bit of magic about them. The dart:io library, which is one of the core Dart libraries, already includes the low-level classes and functions needed to make an HTTP server. So this article will teach you how to create such a server yourself.

Let’s get started. The full code is at the end of the article if you get lost along the way.

Setup

I assume you already have Dart installed. I’m using Dart 2.13 to write this article.

Now create a new Dart project called my_server (or whatever you like) on the command line:

dart create my_server

Open that folder with your preferred IDE. VS Code and IntelliJ both have a Dart plugin. Install it if you haven’t already.

Creating a server

Replace my_server.dart with the following code:

--

--