Skip to content

Package and plugin support

Parker Lougheed edited this page Jan 24, 2024 · 6 revisions

How package support works

DartPad allows users to import a few different kinds of code libraries:

  • Dart SDK libraries like dart:convert
  • Flutter packages like package:flutter/widgets.dart
  • A small group of pre-approved and tested packages from the pub ecosystem, like package:provider or package:http

It does this by analyzing and compiling each user's code inside a stubbed-out project that includes each available library as a dependency. You can see where this is set up in /lib/src/project.dart in the dart-lang/dart-services repo. DartPad uses a stateless backend, which means that each individual instance of dart-services needs to be set up with exactly the same list of packages loaded up and ready to go, since a user's analysis and compilation requests could go to any one of them at any time, even during a single session.

This approach keeps things simple and reliable (and is what made it possible for the DartPad team to implement package support at all), but it also introduces some restrictions. For example, each supported package/version needs to work nicely with the others. If two packages require conflicting versions of the same dependency, for instance, it's a blocker. In addition, because DartPad is a very unique execution environment that neither Flutter nor most packages were truly designed for, each package must be manually tested in order to guarantee that it works.

Adding support for new packages

Adding support for new packages requires a lot of work, and in some cases simply won't be possible. The google_mobile_ads plugin, for example, is destined never to appear in DartPad. However, updating the allowed list of packages with new libraries and occasionally removing an old one is definitely part of the plan going forward.

Here is the process in a nutshell:

  • Anyone who would like DartPad to support a new package should check to see if an issue for that package already exists.
    • If it does, upvote it with a "thumb's up" reaction.
    • If it doesn't, create a new issue with the name of the package and a brief description of why it would be good to support.
  • Once every quarter or so, the team will take a look at the existing package list and all the issues, and then:
    • Remove support for any packages that are no longer needed/maintained.
    • Look at suggestions with a significant number of upvotes, and either:
      • Add support, or
      • (if support isn't possible) close the issue and explain why.

Currently supported packages

  • animations
  • basics
  • bloc
  • characters
  • collection
  • cross_file
  • dartz
  • english_words
  • equatable
  • fast_immutable_collections
  • flame
  • flame_fire_atlas
  • flame_forge2d
  • flame_splash_screen
  • flame_tiled
  • flutter_bloc
  • flutter_hooks
  • flutter_riverpod
  • google_fonts
  • hooks_riverpod
  • http
  • intl
  • meta
  • path
  • petitparser
  • provider
  • quiver
  • riverpod
  • rohd
  • rohd_vf
  • rxdart
  • timezone
  • vector_math
  • video_player
  • yaml
  • yaml_edit

Deprecated packages

The following packages are deprecated for use and set for removal in a future release of DartPad. Please remove all imports and usages of the following packages.

  • tuple
  • js
  • flutter_processing
  • riverpod_navigator

Deprecated Firebase packages

Support for all Firebase packages in DartPad is deprecated and set to be removed. To prepare for this removal, please remove any imports and usages of them in DartPad snippets.

If you'd like to learn more about using Firebase in your Flutter apps, check out Discover Firebase for Flutter!

This deprecation and removal includes the following packages:

  • firebase_core
  • cloud_firestore
  • firebase_auth
  • firebase_analytics
  • firebase_database
  • firebase_messaging
  • firebase_storage