@nxrocks/nx-flutter v9.0.1
nx-flutter
Nx Plugin adding first class support for Flutter in your Nx workspace
Contents
Features
Here is a list of some of the coolest features of the plugin:
- ✅ Generation of Flutter applications/packages/modules/plugins based on Flutter cli API
- ✅ Building, packaging, testing, etc your Flutter projects
✅ Integration with Nx's dependency graph (through
nx dep-graph
ornx affected:dep-graph
): this allows you to visualize the dependencies of any Flutter projects inside your workspace, just like Nx natively does it for JS/TS-based projects!Example of running the
nx dep-graph
command on a workspace with 2 Flutter projects inside...
Setup
You can now use our own
create-nx-flutter
CLI to easily create a Nx workspace, that comes with this plugin pre-installed!Simply run:
# npm npx create-nx-flutter@latest # or # yarn yarn create nx-flutter
and you are good to go‧o‧o‧o! 🚀
More information here: create-nx-flutter
Otherwise, this is the traditional way of setting things up:
1. Creating the Nx workspace
This plugin relies on flutter's command-line
to do its job. So, you must have flutter
installed on your system. If not, head to flutter.dev/docs/get-started/install and follow installation instructions for your OS.
Then, if you have not already, create an Nx workspace with the following:
# npm
npx create-nx-workspace@latest
# yarn
yarn create nx-workspace@latest
2. Installing the Plugin
Then you need to install the plugin in order to generate Flutter applications later on.
# npm
npm install @nxrocks/nx-flutter --save-dev
# yarn
yarn add @nxrocks/nx-flutter --dev
Generators
This plugin is composed of 1 main generator:
project
generator
Generating Projects (project
generator)
Simply run the project
generator with the following command:
nx g @nxrocks/nx-flutter:project <app-folder>
you can also use the following aliases to call the generator:
prj
,new
, orcreate
You will be prompted for entering the most commonly customized generation options (like application's package
, description
, template
, etc).
To skip the interactive prompt, or if you want to customize all non-prompted options, you can pass them along directly when running the command, as such:
nx g @nxrocks/nx-flutter:project <app-folder> --optionName1 optionValue1 ... --optionNameN optionValueN
Generation Options
Here the list of available generation options :
Arguments | Description |
---|---|
<output-folder> | The folder that will contain your app |
Option | Value | Description |
---|---|---|
org | string | Name of the package |
description | string | Description of the project |
androidLanguage | java | kotlin | Language to use for Android code |
iOSLanguage | objc | swift | Language to use for iOS code |
template | app | module | package | plugin | Template of Flutter project to generate |
sample | string | Sample ID of the desired sample from the API documentation website (http://docs.flutter.dev) |
platforms | android | ios | linux | macos | windows | web | Platforms supported by the project to generate |
pub | boolean | Whether to run "flutter pub get" after the project has been created |
offline | boolean | Whether or not to run 'flutter pub get' in offline mode |
tags | string | Tags to use for linting (comma-separated) |
directory | string | Directory where the project is placed |
Executors
Once your app is generated, you can now use executors to manage it.
Here the list of available executors1:
Executor | Arguments | Description |
---|---|---|
analyze | see flutter help analyze | Analyze the project's Dart code |
assemble | see flutter help assemble | Assemble and build Flutter resources |
attach | see flutter help attach | Attach to a running app |
build-aar | see flutter help build aar | Build a repository containing an AAR and a POM file |
build-apk | see flutter help build apk | Build an Android APK file from your app |
build-appbundle | see flutter help build appbundle | Build an Android App Bundle file from your app |
build-bundle | see flutter help build bundle | Build the Flutter assets directory from your app |
build-ios | see flutter help build ios | Build an iOS application bundle (Mac OS X host only) |
buildIosframework | see flutter help build ios-framework | Produces a .framework directory for a Flutter module and its plugins for integration into existing, plain Xcode projects |
build-ipa | see flutter help build ipa | Build an iOS archive bundle (Mac OS X host only) |
clean | see flutter help clean | Delete the build/ and dart_tool/ directories |
drive | see flutter help drive | Run integration tests for the project on an attached device or emulator |
format | see dart help format | Format one or more Dart files |
gen-l10n | see flutter help gen-l10n | Generate localizations for the current project |
install | see flutter help install | Install a Flutter app on an attached device |
run | see flutter help run | Run your Flutter app on an attached device |
screenshot | see flutter help screenshot | Take a screenshot from a connected device |
symbolize | see flutter help symbolize | Symbolize a stack trace from an AOT-compiled Flutter app |
test | see flutter help test | Run Flutter unit tests for the current project |
doctor | see flutter help doctor | Run Flutter doctor to check the environment and status of Flutter installation |
1 : Actual executors in your workspace.json
will depend on the type of flutter
project (template
), target platforms
that you choose to generate.
Each executor is based on an original project-level flutter
command. The name is just kebab-cased to match executors' naming conventions.
Besides, the arguments accepted by each executor, are the same as the original flutter
command they are based upon, encapsulated
under a generic --args='...'
option.
For example:
$ flutter gen-l10n --header "/// my header"
becomes 👉🏾
$ nx gen-l10n your-flutterapp --args='--header="/// my header"'
Note that the original
flutter
command name (gen-l10n
) has been camelcased for creating itsnx-flutter
equivalent (gen-l10n
)Note that the arguments of the original
flutter
command are wrapped under--args='...'
option in thenx-flutter
equivalent
Compatibility with Nx
Every Nx plugin relies on the underlying Nx Workspace/DevKit it runs on. This table provides the compatibility matrix between major versions of Nx workspace and this plugin.
Plugin Version | Nx Workspace version |
---|---|
>=v9.x.x | >=v18.x.x |
>=v8.x.x | >=v17.x.x |
>=v7.x.x | >=v16.x.x |
>=v6.x.x | >=v15.8.x |
>=v5.x.x | >=v15.x.x |
>=v3.1.x | >=v13.8.x |
>=v3.x.x | >=v12.6.x |
>=v2.x.x | >=v11.x.x |
<=v1.3.1 | <=v10.x.x |
License
Copyright (c) 2020-present Tine Kondo. Licensed under the MIT License (MIT)
29 days ago
1 month ago
1 month ago
5 months ago
2 months ago
7 months ago
6 months ago
6 months ago
5 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago