export_files_generator 1.0.9

Recursively scans target folder for Dart projects (identifiable by pubsec.yaml file) and creates export files.

main #

main(List<String> arguments) {
  File root = LocalFileSystem.ApplicationHome();
  if (arguments.length > 0) {
    String targetFolderPath = arguments[0]; //argument containing target folder path
    root = LocalFileSystem.newLocalFile(targetFolderPath);

  if (!root.exists()) {
    Err.reportError("Folder not found: $root");


the code #

static void generate(File root) {
    FileFilter pubsecFilter = (file) => file.getName() == PUBSEC;

    FilesList pubsecFiles = root.listAllChildren(fileFilter: pubsecFilter);

    for (File pubsec in pubsecFiles.toList()) {

  static void processProject(File pubsec) {
    File project_root = pubsec.parent();
    String pubsecData = pubsec.readString();
    final String name = pubsecData.split(N)[0].replaceAll("name: ", "").replaceAll(N, "").replaceAll(R, "");
    L.d("project", project_root);
    L.d("   name", name);

    final File lib = project_root.child("lib");
    final File exportFile = lib.child(name + ".dart");

    FileFilter dartFilter = (file) => file.extensionIs("dart");

    final FilesList dartFiles = lib.listAllChildren(fileFilter: dartFilter);
    final List<String> exportFileContent = [];
    final RelativePath prefix = project_root.getAbsoluteFilePath().getRelativePath();
    for (final File dart in dartFiles.toList()) {
      final RelativePath dart_prefix = dart.getAbsoluteFilePath().getRelativePath();
      List<String> postfix = dart_prefix.steps();
      postfix = postfix.sublist(prefix.size() + 1, postfix.length); //lib
      final RelativePath split = Utils.newRelativePath(path_steps: postfix);
      final String fileName = split.getLastStep();
      if (fileName == ("main.dart")) {
      if (fileName == (exportFile.getName())) {
      exportFileContent.add("export 'package:" + name + RelativePath.SEPARATOR + split.toString() + "';");

    L.d("writing", exportFile);
    String data = exportFileContent.join("");


Changelog #

0.0.1 #

  • Initial version, created by Stagehand

Use this package as a library

1. Depend on it

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

  export_files_generator: ^1.0.9

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.

3. Import it

Now in your Dart code, you can use:

import 'package:export_files_generator/export_files_generator.dart';
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.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.20.1 <2.0.0