dartx 0.0.8

dartx #

The main purpose of dartx is that it allows easy to execute special standalone command-line scripts at any place. These scripts can to require for their operation other packages (uses import directives). They will be executed without requirements manually to install these dependent packages.

Dartx does not have any dependencies and can be distributed with a command-line scripts.

Dartx supports the command-line scripts that contains pubspec.yaml files inside the source code of these scripts.

Example of command-line script (example/serve.dart):

name: serve
description: A sample static server
  shelf: any
  shelf_static: any

import "dart:async";
import "dart:io";
import 'package:shelf/shelf_io.dart' as shelf_io;
import "package:shelf_static/shelf_static.dart";

void main() {
  var path = Directory.current.path;
  var handler = createStaticHandler(path, defaultDocument: "index.html");
  var port = 8080;
  var address = InternetAddress.LOOPBACK_IP_V4;
  shelf_io.serve(handler, address, port).then((server) {
    var address = server.address.address;
    var port = server.port;
    var url = "http://$address:$port";
    print("Static web server (shelf)");
    print("Url: $url");
    print("Path: $path");
    print("Press <ENTER> to exit");
    stdin.listen((data) {
      server.close(force: true);

    Timer.run(() => runBrowser(url));

void runBrowser(String url) {
  var fail = false;
  switch (Platform.operatingSystem) {
    case "linux":
      Process.run("x-www-browser", [url]);
    case "macos":
      Process.run("open", [url]);
    case "windows":
      Process.run("explorer", [url]);
      fail = true;

  if (!fail) {
    print("Start browsing...");

To see it in action perform the following steps:

  1. Go to the dartx/example directory.
  2. Run command $DART_SDK/bin/dart ../bin/dartx.dart serve.dart.

Static web server will be executed even it uses shelf and shelf_static packages but dartx package does not declare in its pubspec.yaml these dependencies.

Principle of operation is very simple:

Before executing script dartx creates temporary directory and tells pub to get dependencies into this temporary directory.

Temporary directory will be deleted after the end of execution of command-line script.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  dartx: ^0.0.8

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.