{"id":9100,"date":"2022-06-21T09:17:51","date_gmt":"2022-06-21T07:17:51","guid":{"rendered":"https:\/\/via-internet.de\/blog\/?p=9100"},"modified":"2022-07-02T10:19:13","modified_gmt":"2022-07-02T08:19:13","slug":"dart-working-with-the-dartcommand-line","status":"publish","type":"post","link":"https:\/\/via-internet.de\/blog\/2022\/06\/21\/dart-working-with-the-dartcommand-line\/","title":{"rendered":"Dart | Working with the DartCommand Line"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Dart Command Line<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To show all commands, just run <code>dart<\/code><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f dart\nA command-line utility for Dart development.\n\nUsage: dart &lt;command|dart-file> [arguments]\n\nGlobal options:\n-h, --help                 Print this usage information.\n-v, --verbose              Show additional command output.\n    --version              Print the Dart SDK version.\n    --enable-analytics     Enable analytics.\n    --disable-analytics    Disable analytics.\n\nAvailable commands:\n  analyze    Analyze Dart code in a directory.\n  compile    Compile Dart to various formats.\n  create     Create a new Dart project.\n  devtools   Open DevTools (optionally connecting to an existing application).\n  doc        Generate API documentation for Dart projects.\n  fix        Apply automated fixes to Dart source code.\n  format     Idiomatically format Dart source code.\n  migrate    Perform null safety migration on a project.\n  pub        Work with packages.\n  run        Run a Dart program.\n  test       Run tests for a project.<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Create a Dart project<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f dart create\nCreate a new Dart project.\n\nUsage: dart create [arguments] &lt;directory>\n-h, --help                       Print this usage information.\n-t, --template                   The project template to use.\n\n          [console] (default)    A command-line application.\n          [package]              A package containing shared Dart libraries.\n          [server-shelf]         A server app using package:shelf.\n          [web]                  A web app that uses only core Dart libraries.\n\n    --[no-]pub                   Whether to run 'pub get' after the project has been created.\n                                 (defaults to on)\n    --force                      Force project generation, even if the target directory already exists.<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Create a Server App<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Create the Project<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f dart create app_server -t server-shelf\nCreating app_server using template server-shelf...\n\n  .gitignore\n  analysis_options.yaml\n  CHANGELOG.md\n  pubspec.yaml\n  README.md\n  Dockerfile\n  .dockerignore\n  test\\server_test.dart\n  bin\\server.dart\n\nRunning pub get...\n  Resolving dependencies...\n  Downloading lints 2.0.0...\n  Downloading shelf_router 1.1.3...\n  Downloading http_methods 1.1.0...\n  Downloading test 1.21.2...\n  Downloading test_core 0.4.14...\n  Downloading test_api 0.4.10...\n  Downloading glob 2.1.0...\n  Downloading frontend_server_client 2.1.3...\n  Downloading analyzer 4.1.0...\n  Downloading _fe_analyzer_shared 40.0.0...\n  Downloading coverage 1.3.2...\n  Changed 49 dependencies!\n\nCreated project app_server in app_server! In order to get started, run the following commands:\n\n  cd app_server\n  dart run bin\/server.dart<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Run the App<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f cd app_server<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f dart run bin\/server.dart<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Create a Web App<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Create the Project<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f dart create app_web -t web\nCreating app_web using template web...\n\n  .gitignore\n  analysis_options.yaml\n  CHANGELOG.md\n  pubspec.yaml\n  README.md\n  web\\index.html\n  web\\main.dart\n  web\\styles.css\n\nRunning pub get...\n  Resolving dependencies...\n  Downloading build_web_compilers 3.2.3...\n  Downloading protobuf 2.1.0...\n  Downloading build_modules 4.0.5...\n  Downloading build_runner 2.1.11...\n  Downloading matcher 0.12.12...\n  Downloading build 2.3.0...\n  Downloading dart_style 2.2.3...\n  Downloading build_resolvers 2.0.9...\n  Changed 58 dependencies!\n\nCreated project app_web in app_web! In order to get started, run the following commands:\n\n  cd app_web\n  dart pub global activate webdev\n  webdev serve<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Run the App<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f cd app_web<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f dart pub global activate webdev\nPackage webdev is currently active at version 2.7.9.\nResolving dependencies...\nThe package webdev is already activated at newest available version.\nTo recompile executables, first run `dart pub global deactivate webdev`.\nInstalled executable webdev.\nActivated webdev 2.7.9.<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f webdev serve<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Serve with different Port as the default port 8080<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f webdev serve web:10000\n[INFO] Building new asset graph completed, took 11.2s\n[INFO] Checking for unexpected pre-existing outputs. completed, took 13ms\n[INFO] Serving `web` on http:\/\/127.0.0.1:10000\n[WARNING] No actions completed for 51.9s, waiting on:\n  - build_web_compilers:entrypoint on web\/main.dart\n\n[INFO] Generating SDK summary completed, took 49.3s\n[WARNING] No actions completed for 15.0s, waiting on:\n  - build_web_compilers:sdk_js on asset:build_web_compilers\/$package$\n  - build_web_compilers:entrypoint on web\/main.dart\n\n[WARNING] No actions completed for 15.0s, waiting on:\n  - build_web_compilers:sdk_js on asset:build_web_compilers\/$package$\n  - build_web_compilers:entrypoint on web\/main.dart\n\n[INFO] Running build completed, took 1m 40s\n[INFO] Caching finalized dependency graph completed, took 1.7s\n[INFO] Succeeded after 1m 42s with 15 outputs (1363 actions)\n[INFO] ---------------------------------------------------------------------<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Create a Command-line App<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Create the Project<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f dart create app_console -t console\nCreating app_console using template console...\n\n  .gitignore\n  analysis_options.yaml\n  CHANGELOG.md\n  pubspec.yaml\n  README.md\n  bin\\app_console.dart\n  lib\\app_console.dart\n  test\\app_console_test.dart\n\nRunning pub get...\n  Resolving dependencies...\n  Changed 46 dependencies!\n\nCreated project app_console in app_console! In order to get started, run the following commands:\n\n  cd app_console\n  dart run<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Run the App<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f cd app_console<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f dart run\nBuilding package executable...\nBuilt app_console:app_console.\nHello world: 42!<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Build an executable for Windows<\/h4>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f dart compile exe .\\bin\\main.dart\nInfo: Compiling with sound null safety\nGenerated: ...\\app_console\\bin\\main.exe<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"10\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f dir bin\n\n    Directory: D:\\CLOUD\\Programmier-Workshops\\Kurse\\Dart\\Einsteiger\\Overview\\app_console\\bin\n\nMode                 LastWriteTime         Length Name\n----                 -------------         ------ ----\n-a---          21.06.2022    10:28            329 main.dart\n-a---          21.06.2022    10:33        5025280 main.exe\n\n\u276f .\\bin\\main.exe\nHello world: 42!<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Use a different App Name as Executable:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Use option -o with dart compile<\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"1\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\u276f dart compile exe .\\bin\\main.dart -o starter.exe\n\u276f .\\bin\\starter.exe<\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>configure name in pubspec.yaml<\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">executables:\n  github_activity: gh_activity<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Dart Command Line To show all commands, just run dart Create a Dart project Create a Server App Create the Project Run the App Create a Web App Create the Project Run the App Serve with different Port as the default port 8080 Create a Command-line App Create the Project Run the App Build an executable for Windows Use a different App Name as Executable: Use option -o with dart compile configure name in pubspec.yaml<\/p>\n","protected":false},"author":1,"featured_media":9101,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[144],"tags":[],"class_list":["post-9100","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dart"],"jetpack_featured_media_url":"https:\/\/via-internet.de\/blog\/wp-content\/uploads\/2022\/06\/dart_header.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts\/9100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/comments?post=9100"}],"version-history":[{"count":8,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts\/9100\/revisions"}],"predecessor-version":[{"id":9173,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/posts\/9100\/revisions\/9173"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/media\/9101"}],"wp:attachment":[{"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/media?parent=9100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/categories?post=9100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/via-internet.de\/blog\/wp-json\/wp\/v2\/tags?post=9100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}