Установка flutter mac os

Get Started: Install on macOS

System requirements

To install and run Flutter, your development environment must meet these minimum requirements:

  • Operating Systems: macOS (64-bit)
  • Disk Space: 700 MB (does not include disk space for Xcode or Android Studio).
  • Tools: Flutter depends on these command-line tools being available in your environment.
    • bash , mkdir , rm , git , curl , unzip , which

Get the Flutter SDK

To get Flutter, use git to clone the repository and then add the flutter tool to your path. Running flutter doctor shows any remaining dependencies you may need to install.

Clone the repo

If this is the first time you’re installing Flutter on this machine, clone the beta branch of the repository and then add the flutter tool to your path:

The above command sets your PATH variable temporarily, for the current terminal window. To permanently add Flutter to your path, see Update your path.

To update an existing version of Flutter, see Upgrading Flutter.

Run flutter doctor

Run the following command to see if there are any dependencies you need to install to complete the setup:

This command checks your environment and displays a report to the terminal window. The Dart SDK is bundled with Flutter; it is not necessary to install Dart separately. Check the output carefully for other software you may need to install or further tasks to perform (shown in bold text).

The first time you run a flutter command (such as flutter doctor ), it downloads its own dependencies and compiles itself. Subsequent runs should be much faster.

The following sections describe how to perform these tasks and finish the setup process. You’ll see in flutter doctor output that if you choose to use an IDE, plugins are available for IntelliJ IDEA, Android Studio, and VS Code. See Editor Setup for the steps to install the Flutter and Dart plugins.

Once you have installed any missing dependencies, run the flutter doctor command again to verify that you’ve set everything up correctly.

The flutter tool uses Google Analytics to anonymously report feature usage statistics and basic crash reports. This data is used to help improve Flutter tools over time. Analytics is not sent on the very first run or for any runs involving flutter config , so you can opt out of analytics before any data is sent. To disable reporting, type flutter config —no-analytics and to display the current setting, type flutter config . See Google’s privacy policy:www.google.com/intl/en/policies/privacy.

Update your path

You can update your PATH variable for the current session only at the command line, as shown in Clone the Flutter repo. You’ll probably want to update this variable permanently, so you can run flutter commands in any terminal session.

The steps for modifying this variable permanently for all terminal sessions are machine-specific. Typically you add a line to a file that is executed whenever you open a new window. For example:

  1. Determine the directory where you placed the Flutter SDK. You will need this in Step 3.
  2. Open (or create) $HOME/.bash_profile . The file path and filename might be different on your machine.
  3. Add the following line and change [PATH_TO_FLUTTER_GIT_DIRECTORY] to be the path where you cloned Flutter’s git repo:

    Run source $HOME/.bash_profile to refresh the current window.

    Verify that the flutter/bin directory is now in your PATH by running:

    Editor setup

    Using the flutter command-line tools, you can use any editor to develop Flutter applications. Type flutter help at a prompt to view the available tools.

    We recommend using our plug-ins for a rich IDE experience supporting editing, running, and debugging Flutter apps. See Editor Setup for detailed steps.

    Platform setup

    macOS supports developing Flutter apps for both iOS and Android. Complete at least one of the two platform setup steps now, to be able to build and run your first Flutter app.

    iOS setup

    Install Xcode

    To develop Flutter apps for iOS, you need a Mac with Xcode 7.2 or newer:

      Install Xcode 7.2 or newer (via web download or the Mac App Store).

    Configure the Xcode command-line tools to use the newly-installed version of Xcode by running sudo xcode-select —switch /Applications/Xcode.app/Contents/Developer from the command line.

    This is the correct path for most cases, when you want to use the latest version of Xcode. If you need to use a different version, specify that path instead.

  1. Make sure the Xcode license agreement is signed by either opening Xcode once and confirming or running sudo xcodebuild -license from the command line.
Читайте также:  Как подключить второй монитор linux mint

With Xcode, you’ll be able to run Flutter apps on an iOS device or on the simulator.

Set up the iOS simulator

To prepare to run and test your Flutter app on the iOS simulator, follow these steps:

  1. On your Mac, find the Simulator via Spotlight or by using the following command:
  1. Make sure your simulator is using a 64-bit device (iPhone 5s or later) by checking the settings in the simulator’s Hardware > Device menu.
  2. Depending on your development machine’s screen size, simulated high-screen-density iOS devices may overflow your screen. Set the device scale under the Window > Scale menu in the simulator.
  3. Start your app by running flutter run .

Deploy to iOS devices

To deploy your Flutter app to a physical iOS device, you’ll need some additional tools and an Apple account. You’ll also need to set up physical device deployment in Xcode.

  1. Install homebrew.
  2. Open the terminal and run these commands to install the tools for deploying Flutter apps to iOS devices.

If any of these commands fails with an error, run brew doctor and follow the instructions for resolving the issue.

  1. Follow the Xcode signing flow to provision your project:
    1. Open the default Xcode workspace in your project by running open ios/Runner.xcworkspace in a terminal window from your Flutter project directory.
    2. In Xcode, select the Runner project in the left navigation panel.
    3. In the Runner target settings page, make sure your Development Team is selected under General > Signing > Team. When you select a team, Xcode creates and downloads a Development Certificate, registers your device with your account, and creates and downloads a provisioning profile (if needed).
      • To start your first iOS development project, you may need to sign into Xcode with your Apple ID.

        Development and testing is supported for any Apple ID. Enrolling in the Apple Developer Program is required to distribute your app to the App Store. View the differences between Apple membership types.
      • The first time you use an attached physical device for iOS development, you will need to trust both your Mac and the Development Certificate on that device. Select Trust in the dialog prompt when first connecting the iOS device to your Mac.

        Then, go to the Settings app on the iOS device, select General > Device Management and trust your Certificate.
      • If automatic signing fails in Xcode, verify that the project’s General > Identity > Bundle Identifier value is unique.
  2. Start your app by running flutter run .
Читайте также:  Zona для windows 10 64 bit

Android setup

Note: Flutter relies on a full installation of Android Studio to supply its Android platform dependencies. However, you can write your Flutter apps in a number of editors; a later step will discuss that.

Install Android Studio

Download and install Android Studio.

Start Android Studio, and go through the ‘Android Studio Setup Wizard’. This will install the latest Android SDK, Android SDK Platform-Tools, and Android SDK Build-Tools, which are required by Flutter when developing for Android.

Set up your Android device

To prepare to run and test your Flutter app on an Android device, you’ll need an Android device running Android 4.1 (API level 16) or higher.

  1. Enable Developer options and USB debugging on your device. Detailed instructions are available in the Android documentation.
  2. Using a USB cable, plug your phone into your computer. If prompted on your device, authorize your computer to access your device.
  3. In the terminal, run the flutter devices command to verify that Flutter recognizes your connected Android device.
  4. Start your app by running flutter run .

By default, Flutter uses the version of the Android SDK where your adb tool is based. If you want Flutter to use a different installation of the Android SDK, you must set the ANDROID_HOME environment variable to that installation directory.

Set up the Android emulator

To prepare to run and test your Flutter app on the Android emulator, follow these steps:

  1. Enable VM acceleration on your machine.
  2. Launch Android Studio>Tools>Android>AVD Manager and select Create Virtual Device.
  3. Choose a device definition and select Next.
  4. Select one or more system images for the Android versions you want to emulate, and select Next. An x86 or x86_64 image is recommended.
  5. Under Emulated Performance, select Hardware — GLES 2.0 to enable hardware acceleration.

Verify the AVD configuration is correct, and select Finish.

For details on the above steps, see Managing AVDs.

  • In Android Virtual Device Manager, click Run in the toolbar. The emulator starts up and displays the default canvas for your selected OS version and device.
  • Start your app by running flutter run . The connected device name is Android SDK built for

    , where platform is the chip family, such as x86.

    Источник

    Введение в Flutter

    Что такое Flutter. Установка

    Flutter представляет фреймворк от компании Google, который позволяет создавать кроссплатформенные приложения, которые могут использовать однин и тот же код. Спектр платформ широк — это веб-приложения, мобильные приложения под Android и iOS, графические приложения под настольные операционные системы Windows, MacOS, Linux, а также веб-приложения.

    Особенностью работы с Flutter является то, что приложения под разные платформы могут иметь один и тот же код. Поскольку используемые платформы не эквиваленты, то какие-то отдельные части кода необходимо настраивать под определенную ОС, например, под iOS, но тем не менее большая часть кода может совпадать. Это позволяет разработчикам существенно сэкономить время и ресурсы на создание приложений под все поддерживаемые платформы.

    В качестве языка разработки используется язык программирования Dart.

    При постороении приложения Flutter транслирует код на Dart в нативный код приложения с помощью Dart AOT (компиляция приложения перед его запуском), которое можно запускать на Android или iOS или другой платформе. Однако при разработке приложения для ее ускорения Flutter использует JIT (компиляция приложения в процессе его запуска).

    Надо отметить, что Flutter относительно новый фреймворк. Хотя прототип фреймворка появился еще в 2015 году, а первая альфа-версия вышла в мае 2017 года, но первый стабильный релиз — Flutter 1.0 увидел свет только в декабре 2018 года. Тем не менее регулярно с небольшой периодичностью ыходят подверсии, добавляя новую функциональноть и исправляя имеющиеся баги. На момент публикации данной статьи последней стабильной версией является Flutter 2.0, которая вышла в марте 2021 года.

    Что используется для разрабоки под Flutter? Для для написания кода программы можно использовать любой полюбившийся текстовый редактор и затем с помощью утилит командной строки из Flutter SDK компилировать приложение. Однако для таких сред как Android Studio и IntelliJ IDEA, а также текстового редактора Visual Studio Code компания Google выпустила специальные плагины, которые позволяют упростить разработку. Поэтому зачастую для разработки под Flutter используются именно Android Studio и IntelliJ IDEA.

    Установка Flutter SDK

    На странице https://flutter.dev/docs/get-started/install/ можно найти ссылки на на загрузку SDK для разных операционных систем. Рассмотрим, как установить Flutter SDK на Windows и MacOS.

    Установка Flutter на Windows

    Чтобы начать разрабатывать приложения с помощью Flutter, необходимо установить SDK. Но прежде всего следует отметить, что для работы Flutter SDK в Windows в системе должен быть установлен Git for Windows, который можно найти по адресу https://git-scm.com/download/win.

    Также Flutter использует Android SDK. Самый легкий способ установить Android SDK — сразу установить Android Studio, вместе с которой будут установлены вс необходимые инструменты.

    Непосредственно для установки Flutter SDK перейдем на страницу https://flutter.dev/docs/get-started/install/windows. На этой странице найдем в секции Get the Flutter SDK ссылку на zip-архив с Flutter SDK и загрузим его:

    Далее распакуем архив, например, на диске С. Например, в моем случае архив распакован в папку C:\flutter .

    В распакованном архиве в папке flutter\bin мы найдем инструменты для компиляции приложения. Например, в моем случае полный путь к этой папке C:\flutter\bin :

    Путь к этой папке нам надо добавить в переменные среды. (Переменные среды можно открыть через Панель управления -> Система -> Дополнительные параметры системы -> Переменные среды).

    Здесь нам надо изменить переменную Path, добавив путь к папке bin в Flutter SDK:

    Чтобы проверить корректность установки Flutter, откроем командную строку и введем команду flutter . Если Windows распознает ее, и последует вывод некоторой справочной информации (например, как использовать те или иные команды в консоли), то flutter установлен и настроен.

    В качестве альтернативы установить Flutter SDK можно через Git. Для этого необходимо в командной строке перейти к папке, где должен располагаться SDK и далее выполнить в командной строке следующую команду:

    В данном случае с репозитария на гитхабе будет загружена последняя стабильная версия Flutter SDK. И опять же подчеркиваю, что для выполнения этой команды необходимо установить Git for Windows, как было написано выше.

    Установка Flutter на MacOS

    Для установки и обновления Flutter использует git , поэтому необходимо установить git. Однако если установлен Xcode , то git устанавливать не надо, так как Xcode уже включает git.

    Для установки Flutter SDK перейдем на страницу https://flutter.dev/docs/get-started/install/macos и найдем на странице ссылку на Flutter SDK и загрузим его:

    Далее поместим папку с Flutter SDK где-нибудь на жестком диске. Например, в моем случае Flutter SDK расположен в корневой папке текущего пользователя ( Users/eugene ).

    Для использования Flutter SDK в треминале, необходимо добавить путь к папке bin в SDK в системные переменные. Добавление для текущего окна терминала:

    При первом использовании команды flutter произойдет загрузка Dart SDK.

    Обновление Flutter

    Если впоследствии необходимо будет обновить Flutter, то для этого достаточно будет выполнить в командной строке команду

    Поскольку Flutter активно развивается, то лучше обновляться регулярно.

    Источник

    Читайте также:  Fixing windows file system
  • Оцените статью