- Install and configure Flutter
Flutter
It’s Google MobileUI
Frame can be quickly iniOS
andAndroid
Build a high quality native user interface, and is the new operating system of the futureFuchsiaThe default development suite for- All over the world,
Flutter
Is being used by more and more developers and organizations, andFlutter
Is completely free and open source —-Because Chinese website Flutter
At the same time supportWindows
,Linux
andMacOS
Operating system as development environment, and inAndroid Studio
andVS Code
twoIDE
Both are fully supportedFlutter
In order toDart
The language is the development language (covered in a later article)
Cross-platform framework
- in
Flutter
Before it was born, there were many cross-platformsUI
Framework schemes, such as basesIn the WebView
theCordova
,AppCan
Etc., and useHTML+JavaScript
Rendered as a native controlReact Native
,Weex
(although I have only used itReact Native
) - Based on the
WebView
The framework of- The advantages are obvious. They can inherit modern times almost entirely
Web
All of the results of development (much richer control libraries, page frameworks to meet various needs, full dynamics, automated testing tools, and so on), of courseWeb
Developers, without much learning and migration costs, can develop oneApp
- The downside can also be fatal. In the case of high requirements for experience and performance,
WebView
Rendering efficiency andJavaScript
Poor execution performance. Coupled with theAndroid
It is difficult to ensure a consistent experience across all devices due to the customization of various system versions and device manufacturers
- The advantages are obvious. They can inherit modern times almost entirely
React Native
A class of frameworks- The final rendering is handed back to the system, though again using classes
HTML+JS
theUI
Build logic, but eventually generate corresponding custom native controls to take full advantage of native controls relative toWebView
High rendering efficiency - At the same time this strategy will also frame itself and
App
Developers are tied to the controls of the system, and not only does the framework itself have to handle a lot of platform-specific logic, as the system version changes andAPI
Developers may also have to deal with differences between platforms, and some features can only be implemented on some platforms, thus reducing the cross-platform nature of the framework
- The final rendering is handed back to the system, though again using classes
Flutter
The frameworkFlutter
It opens up a whole new way to rewrite a cross-platform software from the ground upUI
Framework, includingUI
Controls, rendering logic, and even development languagesFlutter
Use your own high-performance rendering engine to drawwidget
.Flutter
useC
,C ++
,Dart
andSkia
(2D rendering engine) build- in
iOS
On,Flutter
The engine’sC/C ++
Code usingLLVM
Compile, anyDart
The code isAOT
Compiled to native code,Flutter
Applications run with native instruction sets (no interpreter involved) - And in the
Android
Next,Flutter
The engine’sC/C ++
The code is to useAndroid
theNDK
Compiled, anyDart
The code isAOT
Compiling native code,Flutter
The application still runs with the native instruction set (no interpreter involved)
Flutter
The installation
- Please refer to the official websiteInstall the FlutterTo support
Windows
,Linux
andMacOS
The operating system - The system I use is
MacOS
The operating system
System requirements
To install and run Flutter, your development environment must meet the following minimum requirements:
- Operating system: macOS (64-bit)
- Disk space: 700 MB (not included
Xcode
orAndroid Studio
Disk space). - Tools:
Flutter
Rely on the following command-line tools.bash
.mkdir
.rm
.git
.curl
.unzip
.which
To obtainFlutter SDK
Download the SDK
- Go to the
Flutter
Download the latest available installation package from the official website,Go to the Download page - Pay attention to,
Flutter
Channel version is subject to change, pleaseFlutter
Website shall prevail - In addition, in mainland China, you may need to climb the wall to obtain the installation package list or download the installation package. Readers can also go there
Flutter github
Project down to download the installation package,Go to the Download page
Environment configuration
- Unpack the SDK and put all the files in the place you want them to be. It is recommended to place them in the SDK of other development languages, for example
~/Library/Flutter
- To facilitate subsequent use, you need to put the project in the root directory
bin
Path adds environment variablesPATH
In the- Editor open
~/.bash_profile
File, add as follows
- Editor open
# Configure Flutter
# XXX is your own Flutter folder path
export PATH=/xxx/Flutter/bin:$PATH
Copy the code
Since access to Flutter may sometimes be restricted in China, Flutter officials have created a temporary mirror for Chinese developers who can add the following environment variables to their user environment variables:
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
Copy the code
Note that this image is temporary and is not guaranteed to be available all the time. Please refer to Using Flutter in China to get the latest information about the image server
Save the file and update the current configuration
Source ~/.bash_profileCopy the code
Verify that the flutter/bin directory is in your PATH
# Run the following command
echo $PATH
Copy the code
If the installation is successful, a path similar to/XXX /Flutter/bin is displayed
Installing development tools
Install the Android Studio
- Download and install Android Studio
- Start the
Android Studio
And then executeAndroid Studio
Installation wizard, which will install the latestAndroid SDK
.Android SDK
Platform tools andAndroid SDK
Build tools, this isFlutter
The development ofAndroid
Necessary for application - After the installation is complete, configure the required one
Android
The simulator
Install Xcode
Search the App Store for the latest version of Xcode to download and install
VSCode
To develop IDE, go to the official website to download and install
Environment configuration detection
The install of a flutter is now executed using the Flutter doctor command. After a period of download and installation, the flutter will output the installation result (which may take a long time).
$ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [!] ✓ Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.5 17F77, locale EN-NZ) [!] Android toolchain - developfor Android devices (Android SDK 26.0.2)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] iOS toolchain - develop forIOS Devices (Xcode 9.4.1) Qualify Missing Xcode Dependency: Python Module"six".
Install via 'pip install six' or 'sudo easy_install six'Those who qualify qualify libimobiledevice and ideviceinstaller are not installed. To install, run: Brew install --HEAD libiMobileDevice brew install ideviceInstaller onto ios-deploy not installed. To install: Brew install ios-deploy qualify CocoaPods not installed. CocoaPods is used to retrieve the ios platform side's plugin code that responds to your plugin usage on the Dart side. Without resolving iOS dependencies with CocoaPods, plugins will not work on iOS. For more info, see https://flutter.io/platform-plugins To install: Brew Install Cocoapods pod setup [✓] Android Studio Onto university plugin not installed; Those who qualify Dart plugin not installed; This adds Flutter specific functionality. This adds Dart specific functionality. [✓] Android Studio (version 3.0) Eligible Flutter plugin not installed; Those who qualify Dart plugin not installed; This adds Flutter specific functionality. this adds Dart specific functionality. [!] Those who qualify onto university can apply to those who qualify. IntelliJ IDEA Ultimate Edition (Version 2017.1.1) Eligible Flutter plugin not installed; Those who qualify Dart plugin not installed; This adds Flutter specific functionality. this adds Dart specific functionality. [!] VS Code (Version 1.24.1) [!] Connected devices ! No devices available ! Doctor found issues in 5 categories.Copy the code
- In front of it is
[✓]
Indicates that the installation has been successful [!]
Signs need to be installed or updated- The following describes the editor you need to install and its configuration
The development tools
Run the flutter doctor command to see the information
Flutter
Version and information ofFlutter
Run requiredAndroid
Toolchain, some licenses not accepted, type prompt command, typey
confirmFlutter
Run requirediOS
The tool chain is not satisfiedAS
,IDEA
theFlutter
The plug-in is not installed, so it needs to be installed, and therefore configuredAS
orIDEA
- There are connected devices available
Android Studio
- Open the plug-in options
Preferences > Plugins
- choose
Browse repositories
Search,Flutter
Plug-in and install (automatically install at the same timeDart
Plug-in) - After the plug-in is installed, restart it
Android Studio
After plug-in takes effect
Run flutter Doctor on the command line and see that Android Studio is ready
[✓] Android Studio (version 3.2)
Copy the code
IOS configuration
- In the
iOS
Installation is required before configurationCocoaPods
, can be baidu - The installation
CocoaPods
After the executionflutter doctor
Command, the following problems may occur - In this case, run the commands in sequence on the terminal
[!] iOS toolchain - developfor iOS devices
If the command appears, execute the command in sequence. If the command does not appear, do not execute the command$ brew install --HEAD usbmuxd $ brew link usbmuxd $ brew install --HEAD libimobiledevice $ brew install ideviceinstaller ios-deploy cocoapods $ pod setupCopy the code
Run flutter Doctor on the command line and you can see the iOS configuration
VSCode plug-in
Reload the extension to search for the Flutter and Dart installation
Configuration is complete
At this point running the Flutter Doctor command should be no problem
Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14.3 18D109, locale zh-hans -CN) [✓] Android Toolcha-developfor Android devices (Android SDK 28.0.3)
[✓] iOS toolchain - develop forIOS Devices (Xcode 10.1) [✓] Android Studio (Version 3.0) [✓] VS Code (version 1.30.2) [✓] Connected device (1) Available) • No issues found!Copy the code
Create Flutter application
CSCode create
Vscode -> View -> Command Panel -> Flutter: new project -> Enter the project name
Note: Project names do not support capital letters
Android Studio to create
Open Android Studio and you can see the Flutter project template below
Command to create
flutter create helloflutter
Copy the code
A Dart package called Helloflutter is created here
- Parameter is introduced
- To create the plug-in package, use the
--template=plugin
Parameters to performflutter create
- use
--org
Option to specify your organization and use reverse domain name notation. This value is used to generateAndroid
andiOS
Various packages and package identifiers in the code.
flutter create --org com.example --template=plugin helloflutter
Copy the code
- By default, plug-in projects target
iOS
Code usingObjective-C
.Android
Code usingJava
. - If you prefer
Swift
orKotlin
, can be used-i
or-a
为iOS
orAndroid
Specify the language. Such as:
flutter create --template=plugin -i swift -a kotlin helloflutter
Copy the code
Refer to the article
- The principle of Flutter and its practice
- Because Chinese website
When I first learned about Flutter, my summary may not be accurate. Please bear in mind the shortcomings. I will continue to optimize related articles in the future
Please scan the following wechat official account and subscribe to my blog!