zhengxiaoyong

Flutter Wrapper Workflow

The Wrapper Workflow

Use the Flutter Wrapper to get the following benefits:

  • Standardizes a project on a given Flutter version, each Flutter project has its own version of Flutter SDK
  • Provides the same Flutter SDK version for different users and execution environments in a Flutter project

Flutter Wrapper contains the following files:

flutterw
flutterw.bat
flutter/wrapper/flutter-wrapper.properties

The layout of the Flutter project with Wrapper is as follows:

1
2
3
4
5
6
7
8
9
10
.
├── android
├── ios
├── lib/*.dart
├── pubspec.yaml
├── flutter
│ └── wrapper
│ └── flutter-wrapper.properties
├── flutterw
└── flutterw.bat

Develop in multiple projects

Develop in the team

Wrapper Contents

1. flutter-wrapper.properties

The Wrapper properties file, stores the information about the Flutter distribution. It contains the repository url and version of Flutter SDK.

Example:

distributionUrl=https://github.com/flutter/flutter.git
flutterVersion=v1.0.0

The flutterVersion can be a branch name or a tag name

Using a private repository: Example:

distributionUrl=https://gitlab.xxx.net/flutter/flutter.git
flutterVersion=master

2. flutterw/flutterw.bat

The Flutterw script file, a shell script and a Windows batch script for executing the build with the Wrapper.

Adding the Flutter Wrapper

Generating the Wrapper files requires an installed version of the Flutter runtime on your machine as described in Installation.

Automatic

When using flutter create to create a new Flutter project. The Flutter project will include the Wrapper files automatically.

Manual

Executing the wrapper command generates the necessary Wrapper files in the Flutter project directory.
Running the Wrapper task

1
$ flutter wrapper

Cache dir of Flutter Wrapper

The Wrapper will download the required Flutter SDK version automatically.

1. In Windows

1
%USERPROFILE%\AppData\Local\Flutter

2. In UN*X

1
$HOME/Library/Flutter

Using the Flutter Wrapper

Using flutterw is almost the same as using flutter. Depending on the operating system you either run flutterw or flutterw.bat instead of the flutter command.

1. In Windows

Executing the build with the Wrapper batch file in Flutter project:

1
$ flutterw.bat build

2. In UN*X

Executing the build with the Wrapper shell file in Flutter project:

1
$ ./flutterw build
坚持原创技术分享,您的支持将鼓励我继续创作!