I am not able to generate the documentation of the code by using the dartdoc tool located at C:\flutter\bin\cache\dart-sdk\bin. This is what I do:
Go to the project dir dir C:\Users\alber\Documents\progetto_fomet\fomet_app\lib
Call the command dartdoc
It works because in C:\Users\alber\Documents\progetto_fomet\fomet_app\lib\doc\api I see the documentation but it doe NOT include the documentation of my code!
The tool generates the doc of dart like here
but it does NOT generate the doc of my app in flutter
In red you see the source of my app that is not being doc-generated in doc\api. What to do?
I am on Windows 10
I was struggling with this a lot.
Solved by the following steps using the PowerShell:
Installing CHOCOLATEY from https://chocolatey.org/install#individual
Activating dartdoc using flutter pub global activate dartdoc
Activating dhttpd using flutter pub global activate dhttpd
Generating the documentation dartdoc on the project folder
Viewing the generated files using dhttpd --path doc/api
Alternatively on macOS you can use Homebrew to install the dartdoc and dhttpd
Related
I have tried running the terminal command:
flutter config --enable-macos-desktop
but it gives me error:
The "--platforms" argument is not supported in package template
for an existing project just run
flutter create --platforms=macos .
See also here some official docs from the flutter website:
https://docs.flutter.dev/development/platform-integration/desktop#add-desktop-support-to-an-existing-flutter-app
I have found work around:
copy mac os folder from a new natural flutter project(non-package):
open terminal & run:
cd example/macos
3.run:
pod install
then
flutter run
I am trying to install the flutter version manager to switch the flutter version among the different flutter projects.
I use the command to install the fvm - pub global activate fvm
but when I run the command on the terminal - fvm help
There is an error -bash: fvm: command not found
How to fix it ?
Your .pub-cache binaries are not yet added to your PATH variable, used by your terminal. Add path with the following command:
export PATH="$PATH:$HOME/.pub-cache/bin"
This is the location where fvm is installed. So by exporting this path to your PATH variable you should be able to get fvm working from anywhere in your terminal.
If you installed fvm using pub and you already have it in your path but you are still getting the error, follow these steps:
run dart pub cache repair // You may get an error: Failed to precompile fvm:main:. Just ignore that for now.
run dart pub global activate fvm
you can do a
flutter clean
then when its done, run
dart pub global activate fvm
when it's done it should work now, close the current bash terminal and open a new one
You must add the path to the fvm executable to the $PATH environment variable. After running "pub global activate fvm" you should have seen a warning with instructions on how to fix it. You can watch this: https://youtu.be/R6vKde1vIGQ
That will get you up and running.
if use windows 10 or later add system properties -> Environment Variables -> Path -> %USERPROFILE%\AppData\Local\Pub\Cache\bin
First confirm if fvm.bat is executing successfully, you should have the folder already in environment variable PATH(%USERPROFILE%\AppData\Local\Pub\Cache\bin). If it is then for fvm to run in bash, instead of fvm.bat, you need to create a shortcut, a file named fvm with no extension, the containing folder should also exist in PATH variable, the file contains location to fvm.bat and ends with a whitespace and S*.
I just added the the fvm package to switch the flutter channel from stable to master without downloading sdk components every time when switching flutter channels.
I have followed the step written in readme.md for switching the channel.
I have set the following path in my environment variables.
D:\Program_Files\FlutterSDK\SDK\flutter\bin;
D:\Program_Files\FlutterSDK\SDK\dart-sdk\bin;
C:\Users\User\AppData\Roaming\Pub\Cache\bin;
Now, i have opened my first project in which i want to use "flutter SDK's master channel". But, whenever i try to use the command "fvm use master". It's not working.
It is giving me an error like,
'fvm' is not recognized as an internal or external command,
So, can anyone suggest a solution?
Thanks.
try :
pub global run fvm:main
pub global run fvm:main use VERSION
Hi adding in your path:
%LOCALAPPDATA%\Pub\Cache\bin
More info:
https://dart.dev/tools/pub/cmd/pub-global#running-a-script-from-your-path
In my case fvm commands did not work on Windows even tho I checked everything. It gave missing fvm.exe file and other errors. If you also stuck there you can use this way. Only way I managed to get it work is to use longer commands like these:
flutter pub global run fvm:main list
Seems like all fvm commands:
config Set configuration for FVM
flutter Proxies Flutter Commands
install Installs Flutter SDK Version
list Lists installed Flutter SDK Version
releases Lists Flutter SDK releases.
remove Removes Flutter SDK Version
use Which Flutter SDK Version you would like to use
version Prints the currently-installed version of FVM
Works like this, you just need to add the fvm command to the ending of this - flutter pub global run fvm:main. So add any of them like this form:
flutter pub global run fvm:main releases
flutter pub global run fvm:main install 2.2.0
flutter pub global run fvm:main use 2.2.0
are you add "C:\flutter\bin\cache\dart-sdk\bin" to path?
if you in windows you should run your text editor as administrator as following
In my case Error Message was
Usage Error: Flutter version null is not installed
To fix this:
I have activated FVM by pub global activate fvm;
Printed installed fvm list by fvm list, it should give result as the image below:
Selected which Flutter SDK version to use by running fvm use 1.22.0 (in my case 1.22.0, it may differ according to your desired version) command, It will download SDK if it is not installed yet;
Now you can check is flutter running in your project by running flutter;
Also, you can check if the Flutter SDK version set by calling again fvm list.
The tick means, that version is running in your project.
I am trying to run dartdoc for my flutter package but I am getting this,
dartdoc failed: Top level package requires Flutter but FLUTTER_ROOT environment variable not set.
How to add FLUTTER_ROOT environment variable as I have already added environment variable for Flutter SDK and that's working fine, I am just getting issue while running dartdoc. I am a Linux user.
try running flutter pub global run dartdoc:dartdoc instead
If you wish to generate API documentation locally on your development machine, use the following commands:
Change directory to the location of your package:
cd ~/dev/mypackage
Tell the documentation tool where the Flutter SDK is located (change the following commands to reflect where you placed it):
export FLUTTER_ROOT=~/dev/flutter # on macOS or Linux
set FLUTTER_ROOT=~/dev/flutter # on Windows
Run the dartdoc tool (included as part of the Flutter SDK), as follows:
$FLUTTER_ROOT/bin/cache/dart-sdk/bin/dartdoc # on macOS or Linux
%FLUTTER_ROOT%\bin\cache\dart-sdk\bin\dartdoc # on Windows
link https://flutter.dev/docs/development/packages-and-plugins/developing-packages
I'm trying to generated proto file to dart file with protoc-plugin follow this instruction https://grpc.io/docs/quickstart/dart/ but when I run this command line
protoc --dart_out=grpc:lib/proto --plugin=protoc-gen-dart=C:/src/flutter/flutter/.pub-cache/bin/protoc-gen-dart.bat -Iprotobuf protobuf/utils.proto
And it showed this error:
'dart' is not recognized as an internal or external command,
operable program or batch file.
'pub' is not recognized as an internal or external command,
operable program or batch file.
--dart_out: protoc-gen-dart: Plugin failed with status code 1.
I have installed dart as a plugin in my Android Studio. Is that I have to install dart SDK and add it to environment variable path to work?
Update
It worked after i install dart sdk and restart my pc.
Seeing the Flutter tag, I presume that Flutter SDK was what you had before you install Dart SDK as said in your update.
If you want to do this without having to install Dart SDK separately (since Flutter SDK has Dart SDK within itself already), the environment has to know where the following are at:
Flutter SDK
eg: export PATH="~/desktop/development/flutter/bin:$PATH"
Dart SDK within Flutter SDK
eg: export PATH="~/desktop/development/flutter/bin/cache/dart-sdk/bin:$PATH"
Pub cache within Flutter SDK (where the protoc plugin will be located at)
eg: export PATH="$PATH":"$HOME/desktop/development/flutter/.pub-cache/bin"
The given examples above are from .bash_profile in macOS, but in essence, the environment has to know where these 3 are before trying to globally activate the plugin via flutter pub global activate protoc_plugin and then generate Dart code from proto files.
The file protoc-gen-dart.bat actually has bugs in it. It's trying to run exe called pub which doesn't exist. You need to manually edit the file. It should be
dart pub global run protoc_plugin:protoc_plugin %*
not
pub global run protoc_plugin:protoc_plugin %*
Once I changed this, I was able to generate protos for Dart on Windows