0

The first problem I encountered — and which I think is related to the main one — is with respect to the FLUTTER_ROOT variable.

I don't know why it wasn't preset at some point in the installation, but, anyway, I just can't seem to set it from within VS Code, not even if I open it with administrator permissions.

If I run dartdoc in VS Code I get the following error:

Documenting <package_name>...

dartdoc failed: Top level package requires Flutter but FLUTTER_ROOT environment variable not set.

My configurations:

  • My top-level bin folder for Flutter is located at C:\src\flutter\flutter.
  • My FLUTTER_ROOT environment variable has the C:\src\flutter\flutter value for both my user and the system.

If I run it with permissions in Powershell or Command Prompt, it parses every dart core library (dart-async, dart-collection, dart-core, etc.) and every Flutter core library, which I think is understandable to generate my library's docs, but then it also generates docs for all of those dart core libraries. Is this the intended behavior?

Philippe Fanaro
  • 6,148
  • 6
  • 38
  • 76

2 Answers2

1

I still don't know why this is happening or if it's intended, but one thing that has worked for me is:

dartdoc --include <library_name>

This will make sure only your package is included in the docs and not its dependencies. From dartdoc --help:

--include: Library names to generate docs for.

Just make sure to restart dhttpd:

dhttpd --path doc/api

That all still doesn't explain the trouble I had with the FLUTTER_ROOT environment variable (Windows) though.

Philippe Fanaro
  • 6,148
  • 6
  • 38
  • 76
  • 1
    As noted in the GitHub issue I referenced above, `FLUTTER_ROOT` is normally set internally by the `flutter` script, so in most cases users aren't expected to set it themselves. – jamesdlin Apr 16 '20 at 22:27
  • Did that happen with me because I did 1 extra nesting (accidentally) when storing my Flutter SDK? (`C:\src\flutter\flutter` instead of `C:\src\flutter`) – Philippe Fanaro Apr 16 '20 at 22:47
  • Again, as note in the GitHub issue, it's currently expected that you have to set `FLUTTER_ROOT`. The GitHub issue is about providing a way to avoid that. – jamesdlin Apr 16 '20 at 22:57
  • You're right, I was too tired and lacked the attention when I read that Github Issue. I couldn't even note that you're its author. – Philippe Fanaro Apr 17 '20 at 20:07
0

I also had trouble with FLUTTER_ROOT environment variable from dartdoc, but solved it by setting the environment variable as shown in the image below.

<code>FLUTTER_ROOT</code>

Philippe Fanaro
  • 6,148
  • 6
  • 38
  • 76