Flutter, where is the Dart? - flutter

So, I've downloaded flutter SDK 1.17.5-stable and installed it following the manual but I confused a little bit by tutorial.
According to manual:
As of Flutter’s 1.19.0 dev release, the Flutter SDK contains the dart command alongside the flutter command so that you can more easily run Dart command-line programs.
But flutter/bin has only a single binary, flutter itself. According to this answer I found dart binary located within bin/cache/dart-sdk.
I definitely can add path to this directory to my .zshrc and it will work, but I would like to know if it intended behavior and manual just not updated and I haven't done anything wrong.

Mystery solved! I didn't pay attention that 1.17.5 < 1.19.0 and 1.19.0 still in beta/dev channels as of date 15/Jul/2020, so tutorial was updated for release which hasn't been released yet.

Related

Ubuntu | Flutter Doctor: dart is not in you current flutter SDK

Warning: `dart` on your path resolves to /usr/lib/dart/bin/dart, which is
not inside your current Flutter SDK checkout at /home/ankit/flutter.
Consider adding /home/ankit/flutter/bin to the front of your path.
This exception started when the flutter was updated. How do I solve this?
The Problem:
This is happening because you have a separate installation of Dart on your system. The Flutter SDK includes and manages it's own dart SDK, but you can use the dart SDK separately.
Why it Matters
Flutter recommends that you use the dart SDK included with Flutter because Flutter manages it - It will automatically use and upgrade supported versions when using the flutter upgrade command on your terminal, and during initial install.
Flutter is noticing that you have a dart SDK install that did not come with the Flutter SDK. It's giving you a warning because of the possible differences in versions (and possibly other configurations) that could prevent an optimal flutter development experience.
System Path
Here's an explanation of path. You will probably need to set your path environment variables to get the whole fix.
This link shows the official Apple guide to working with the terminal environment variables (including path) but a quick google around should help you find any answers you can't find here.
The path resolves from "front" to "back" - meaning that if the executable in question occurs twice, it will grab the first one. Flutter doctor wants you to add the flutter dart path at the front so that subsequent dart calls will resolve to the Flutter Dart SDK.
The High-Level Solution
Unless you're doing dart development outside flutter, you don't need an additional dart SDK. Most of the time the Flutter dart SDK will work for cases besides flutter as well.
I would recommend removing your other dart install, and using the dart install that comes with flutter. This process will vary depending on how you installed the other dart SDK.
TLDR/Quick Fix
based on what you provided, run this on your Zsh command-line:
export PATH="/home/ankit/flutter/bin:$PATH"
It will only work until you restart your computer.

Flutter version used in project

Where can I see the flutter version used in a flutter project? Is there a file inside the project directory where I can see it? I think it is not specified inside the pubscpec.yaml file
So far, I think the specific version can not be found but only what versions can be used in a project. It can be found at the bottom part of pubscpec.lock file
pubspec.lock screenshot
It will not show version project wise. It will overall flutter version that you have installed in your system. For that:
Open your flutter project root directory in Command Prompt or Terminal type:
flutter --version command.
After typing the above command hit enter and You’ll see it will display us the currently installed flutter and Dart version in your computer and also tells us which version type we have installed like Stable or Beta.
Note: There is no such feature/command to check about which version of flutter you have used in Specific project.
Check this thread it will give you more idea:
https://github.com/flutter/flutter/issues/14230
All projects you run will use the flutter sdk installed in your machine/computer from where you specified its location from. So if the version the project uses don't match with the version you've and they conflict, you will have errors and if there is a huge gap and breaking changes, you'll need to either upgrade or downgrade the sdk. But most of the time, things are deprecated before they just become breaking changes and so you shouldn't have big issues. So the best thing to do is usually to upgrade. First check your sdk version via flutter --version. If its outdated, use flutter upgrade to upgrade it.
You can either run flutter --version to check flutter version installed on your machine or check it in your pubspec.lock file for current flutter version in your project
sdks:
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.16.0 <2.0.0"

Flutter device daemon #1: process exited during startup

the dart path is correct, the environment variable also fine but I can not figure what went wrong, I can not create or run flutter projects. I don't know what is the is please help me figure out this.
There could be chances that you've installed a Flutter before and Flutter took parts of the old version to initialize. Here is a related GitHub post.
Usually a workaround here is to remove or delete flutter_tools.stamp.
rm FLUTTER_ROOT/bin/cache/flutter_tools.stamp
But for most, replacing the existing Flutter SDK with the new one from the Flutter website works like charm.

How to use both Flutter stable and dev SDK on the same machine?

I'm working with Flutter to make a Mobile App using the stable Flutter SDK release. But I also want to try Flutter Desktop and Flutter Web that are not part of the Flutter stable channel yet, but are present on the Flutter dev channel.
My question is... How can I try Flutter Desktop and Flutter Web without override the Flutter stable release on my machine?
You'll need to setup alias to switch between different environments easily.
See here a detailed article for that.
I found this Dart package called Flutter Version Management that does exactly what I want.
As the docs says:
Flutter Version Management: A simple cli to manage Flutter SDK versions.
Features:
Configure and use Flutter SDK version per project
Ability to install and cache multiple Flutter SDK Versions
Fast switch between Flutter channels & versions
Dynamic SDK paths for IDE debugging support.
Version FVM config with a project for consistency across teams and CI environments.
Set global Flutter version across projects
https://github.com/leoafarias/fvm
Now I just need to add FVM_HOME/default/bin to the PATH and FVM will take care of everything...
Two solutions
Put the installation files in two different directories one with stable and the other dev and add one of them to the path then you can change the path variable when needed to use the other channel.
Put the flutter repository file in two different directories one with stable and the other with dev then,
add the first installation to the path then add an alias to point to the second installation directory.

How can i 'complete' my dart SDK rather than installing a separate version when using flutter?

I installed flutter by downloading and installing a release version.
It contains a partial dart SDK in its cache subfolder.
Namely, it's missing (amongst others executables) dart2native.
I realize I could just download and install a separate dart SDK from their website, then change all my paths to point to this newer, complete SDK. But that's exactly the problem - I do not wish to run 2 sdk version in parallel, it's confusing and likely will cause errors down the line (for example, my copy of android studio might be pointing at this or that SDK, and god knows what other tools might point towards it).
Question: is there a way to 'fill' my flutter dart SDK with the missing tools? Or am i doomed to run 2 version of dart SDK in parallel?
Answering my own question - after much googling, I found a repo maintainer stating that "For now, if you want to do to Dart development and use the Dart terminal commands (like dartfmt, pub, or dart2native), it's recommended that you download and install the Dart SDK. If you'd like you can also add it to path."
This is clearly sub-optimal. In fact just as I expected it seems to have led to a few people having faced issues, comment on https://github.com/flutter/flutter/issues/43968 if you'd like to see this addressed.