package:dartpad is a library for building web applications that enable users to prototype Dart and Flutter in the browser.
This package provides the functionality for running a Dart or Flutter development environment in the browser. By enabling you launch and communicate with:
dart pub commands for dependency resolution.iframe containing bootstrap code necessary to:To build a custom dartpad-like experience, you simply have to launch the worker, connect the language server to your editor, connect a sandboxed iframe and tell the sandbox what code to run, while presenting console output to the user.
To launch a Web Worker pre-compiled wasm worker and associated assets are available inside web/ in package:dartpad. You must extract and host these files to provide an absolute URL for DartPadSdk(assetBaseUrl: myUri).
import 'package:dartpad/dartpad.dart'; Future<void> main() async { final sdk = DartPadSdk( // Absolute URL for files in web/ folder of package:dartpad assetBaseUrl: Uri.base.resolve('web/'), ); final dartpad = await sdk.dedicatedWorker(); final ws = await dartpad.createWorkspace(); await ws.writeFileFromText( 'main.dart', 'void main() => print("hello world");', ); }
As of writing there are no support for:
build_runner.It might be possible to support some of these features in the future.