Dart Frog - Backend with Dart

Engineering

Dart Frog

Very Good Ventures

Summary

Dart Frog, an experimental framework by Very Good Ventures, optimizes backend development for Dart and Flutter, enabling shared tools and models. It includes dynamic routing, middleware, and extensive testing support, offering a simpler core and minimal API to streamline development. To start with Dart Frog, install the Dart SDK, activate Dart Frog CLI, create a project, and deploy using provided commands.

Key insights:
  • Dynamic Content: Server-side Dart enables dynamic content tailored to user preferences.

  • Dart Frog Introduction: Dart Frog offers a unified framework for Dart backend, enhancing service flexibility and integration.

  • Core Features: Includes dynamic routing, middleware, hot reload, and comprehensive testing tools.

  • Getting Started: Install Dart SDK, activate Dart Frog CLI, create and deploy projects with simple commands.

  • Optimized Development: Simplifies backend development with shared tools and reduced complexities.

Overview of Dart on the Server

Most large-scale websites use server-side code to dynamically display different data when needed, generally pulled out of a database stored on a server and sent to the client to be displayed via some code.

The most significant benefit of server-side code is that it allows you to modify the website content for individual users. Dynamic sites can highlight content that is more relevant based on user preferences and habits.

The primary focus of Dart 2 is building a common front-end that Dart code is processed through; code will go through the same toolchain, regardless of whether it targets the Dart Virtual Machine or JavaScript.

The need for an Improved Backend Framework for Dart

Using dart language, it is possible to develop the front and back ends of an application together. However, in Dart backend, there is no framework like Flutter that is easy to comprehend, suits community development and utilizes the class structure.

Flutter developers mainly employ Firebase for backend development. While frameworks like Firebase have many advantages, many developers feel that there is a need for improvement in service flexibility, pricing policy, and integration of third-party apps. 

Dart Frog: Redefining approach to Backend Development

Felix Angelov in this blog post announced that Very Good Ventures have launched an experimental framework called ‘Dart Frog’ that helps developers successfully build backends using Dart. Dart Frog would enable Dart and Flutter developers to utilize a combined set of tools that would let them share tools and models. 

It also entails a simple core and a minimal Public API in order to reduce complexities, ramp-up, and user-load time. Dart Frog aims to optimize the backend development approach by having backends that aggregate and utilize data from multiple sources.

Features

  • Dart Development Tools

  • Improve HTTP method specification per handler

  • DartFrog Testing Library (utilities for unit and e2e testing)

  • CLI new command to generate new routes and middleware

  • Hot Reload

  • File System Routing

  • Index, Nested & Dynamic Routes

  • Dependency Injections

  • Production Build

  • Docker

  • Generated Dart Client Package

  • Generated API Documentation

How to Start using Dart Frog?

  1. Make sure that you have Dart SDK installed on your device

  2. Install Dart Frog from the Github source by entering the command: dart pub global activate dart_frog_cli

  3. Create a new project using dart_frog create command

  4. Open the dev server using the dart_frog dev command

  5. Create a production build using dart_frog build command

How does Dart Frog modify the Backend approach?

Dynamic Routes

Dynamic routes require routers to exchange information with other routers to learn about paths through the network. Dart Frog supports dynamic routes. For instance, if you create a file called routes/posts/<id>.dart, it will be accessible at /posts/1, /posts/2, etc. Routing parameters will then be forwarded to OnRequest

Dynamic Routes are straightforward to configure, adapt to network topology changes, and work well in a network with multiple routes.

Middleware

Middleware are a bunch of commands that are stacked on the pipeline to handle requests (calls made by the user to your server and can contain different types of parameters)

Using Dart Frog, you can execute code before and after a request is processed. You can modify the inbound request, outbound responses, and provide dependencies. This will be possible by a piece of middleware consisting of a middleware function exported from a _middleware.dart file within a subdirectory of the routes folder.

Testing

Dart primarily focuses on three kinds of testing: ‘Unit’, ‘Component’, ‘Integration, and end to end tests. The package:test is a useful Dart library for writing tests through which you can write single tests, groups of tests, write asynchronous tests and use the @TestOn to restrict tests to run on specific environments.

Using Dart Frog, you can now run unit tests on route handlers and middleware successfully. This is made possible by the package:test

Dependencies

Dependency Injection is a way of making the dependencies of an object available via another object, and these dependencies are usually known as services. In dart, the most basic way to handle dependency injection is by passing services to a class through the constructor.

Dart Frog allows Middleware(constructor) to provide dependencies to a RequestContext(Class) via a provider. RequestContext contains information about the HTTP request in the HttpContext property

Provider is a T-class middleware that manages the lifecycle of the value it provides by delegating to a pair of Create and Dispose. It can create and provide a type T instance to the request context.

Stay Ahead of the Game: Subscribe to Our Newsletter

Stay up-to-date with the latest tech news and valuable insights by subscribing to our newsletter today! Get exclusive content delivered straight to your inbox and be ahead of the game. Don't miss out, join our community now!

Subscribe to receive the most exclusive and exciting content delivered straight into your inbox.

Other Insights

Got an app?

We build and deliver stunning mobile products that scale

Got an app?

We build and deliver stunning mobile products that scale

Got an app?

We build and deliver stunning mobile products that scale

Got an app?

We build and deliver stunning mobile products that scale

Got an app?

We build and deliver stunning mobile products that scale

Our mission is to harness the power of technology to make this world a better place. We provide thoughtful software solutions and consultancy that enhance growth and productivity.

The Jacx Office: 16-120

2807 Jackson Ave

Queens NY 11101, United States

Book an onsite meeting or request a services?

© Walturn LLC • All Rights Reserved 2024

Our mission is to harness the power of technology to make this world a better place. We provide thoughtful software solutions and consultancy that enhance growth and productivity.

The Jacx Office: 16-120

2807 Jackson Ave

Queens NY 11101, United States

Book an onsite meeting or request a services?

© Walturn LLC • All Rights Reserved 2024

Our mission is to harness the power of technology to make this world a better place. We provide thoughtful software solutions and consultancy that enhance growth and productivity.

The Jacx Office: 16-120

2807 Jackson Ave

Queens NY 11101, United States

Book an onsite meeting or request a services?

© Walturn LLC • All Rights Reserved 2024

Our mission is to harness the power of technology to make this world a better place. We provide thoughtful software solutions and consultancy that enhance growth and productivity.

The Jacx Office: 16-120

2807 Jackson Ave

Queens NY 11101, United States

Book an onsite meeting or request a services?

© Walturn LLC • All Rights Reserved 2024

Our mission is to harness the power of technology to make this world a better place. We provide thoughtful software solutions and consultancy that enhance growth and productivity.

The Jacx Office: 16-120

2807 Jackson Ave

Queens NY 11101, United States

Book an onsite meeting or request a services?

© Walturn LLC • All Rights Reserved 2024