1. Introduction to flutter
Flutter Widget is built using a modern responsive framework, which is inspired by React. The central idea is to use Widgets to build UIs. Widgets describe what their views should look like given their current configuration and state. When the widget's state changes, the widget will rebuild the UI, and Flutter will compare the changes before and after to determine the minimum change required for the underlying rendering tree to transition from one state to the next.
Flutter is developed using the dart language. It is best to have a basic knowledge of Dart before using it.
2. Installation
There are detailed installation steps on flutter Chinese website
- HomeBrew needs to be installed first
- Download Flutter
- run
flutter doctor
- Follow the prompts to install the configuration file
3. Upgrade Flutter in the project
1. Flutter branch
stable
: flutter stable branch.
master
: Development branch, you can view the latest changes, low stability.
To view the currently used branch, run flutter channel
switch branch, flutter channel beta
orflutter channel master
2. Develop Flutter SDK for the project
pubspec.yaml
Flutter SDK dependencies can be specified in files. For example, the following code snippet specifies flutter
and flutter_test
packages use the Flutter SDK.
name: hello_world
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_test:
sdk: flutter
Do not use the pub get
or pub upgrade
command to manage your dependencies. Instead, use flutter packages get
or flutter packages upgrade
. If you want to use pub manually, you can FLUTTER_ROOT
run it directly by setting environment variables.
3. Upgrade Flutter channel and packages
pubspec.yaml
To update both the Flutter SDK and your dependencies, run the command in your application root directory (the directory containing the files) flutter upgrade
:
$ flutter upgrade
4. Upgrade your dependencies
If you modified pubspec.yaml
the file, or just want to update the packages your app depends on (excluding the Flutter SDK), use the following command:
flutter packages get
Getpubspec.yaml
all dependent packages listed in the fileflutter packages upgrade
Getpubspec.yaml
the latest version of all dependent packages listed in the file