From 22e1d4da0b6cf2a2e528aad46f10a8b1f3d71557 Mon Sep 17 00:00:00 2001 From: leoafarias Date: Sat, 1 May 2021 19:29:39 -0400 Subject: [PATCH] null casting issue and version bump --- CHANGELOG.md | 4 + README.md | 230 +---------------------------- lib/src/models/settings_model.dart | 4 +- lib/src/version.dart | 2 +- pubspec.yaml | 2 +- 5 files changed, 12 insertions(+), 230 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 918b8168..09c48f4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.1 + +- Fix issue when retrieving settings [#281](https://github.com/leoafarias/fvm/issues/281) + ## 2.0.0 - Feature: Environments - Set Flutter sdk versions per project environment. diff --git a/README.md b/README.md index 4466f953..9cc2564f 100644 --- a/README.md +++ b/README.md @@ -18,235 +18,13 @@ FVM helps with the need for a consistent app builds by allowing to reference Flu - Version FVM config with a project for consistency across teams and CI environments. - Set global Flutter version across projects -### The app has moved to a different repo and is now Flutter Sidekick. +[Read the FVM documentation](https://fvm.app) -[Read more about it here.](https://github.com/leoafarias/sidekick) +--- -[![FVM App Screenshot](https://github.com/leoafarias/sidekick/blob/main/assets/sidekick.png?raw=true)](https://github.com/leoafarias/sidekick) +### Checkout Flutter Sidekick. [Read more about it here.](https://github.com/leoafarias/sidekick) -## Version Management - -This tool allows you to manage multiple channels and releases, and caches these versions locally, so you don't have to wait for a full setup every time you want to switch versions. - -Also, it allows you to grab versions by a specific release, i.e. `v1.2.0` or `1.17.0-dev.3.1`. In case you have projects in different Flutter SDK versions and do not want to upgrade. - -## Usage - -1. [Install Dart](https://www.dartlang.org/install). -2. Activate Fvm: - -```bash -> pub global activate fvm -``` - -[Read dart.dev docs for more info](https://dart.dev/tools/pub/cmd/pub-global#running-a-script) on how to run global dart scripts. - -And then, for information on each command: - -```bash -> fvm help -``` - -### Install a SDK Version - -FVM gives you the ability to install many Flutter **releases** or **channels**. - -- `version` - use `stable` to install the Stable channel and `v1.8.0` or `1.17.0-dev.3.1` to install the release. -- `--skip-setup` - will skip Flutter setup after install - -```bash -> fvm install {version} -``` - -#### Project Config SDK Version - -If you configured your project to use a specific version, run `install` without any arguments will install the proper version. - -```bash -> fvm install -``` - -Check out `use` command to see how to configure a version per project. - -### Use a SDK Version - -You can use different Flutter SDK versions per project. To do that you have to go into the root of the project and: - -```bash -> fvm use {version} -``` - -**Set Global Version** - -If you want to use a specific version by default in your machine, you can specify the flag `--global` to the `use` command. A symbolic link to the Flutter version will be created in the `fvm` home folder, which you could then add to your PATH environment variable as follows: `FVM_HOME/default/bin`. Use `fvm use --help`, this will give you the exact path you need to configure. - -:warning: **Do not activate fvm using `flutter pub global activate`** if you plan on using the `--global` flag. Only activate fvm using `pub global activate fvm`. - -```bash -> fvm use {version} --global -``` - -**Force Flag** - -Fvm only allows to call the use command on Flutter projects. However if you want to call the `use` command on a non-flutter directory use the `--force` flag. - -If you are starting a new project and plan on using `fvm flutter create` you wil have to use the `--force` flag - -```bash -> fvm use {version} --force -``` - -### Remove a SDK Version - -Using the remove command will uninstall the SDK version locally, this will impact any projects that depend on that version of the SDK. - -```bash -> fvm remove {version} -``` - -### Upgrade the current SDK Version - -To upgrade currently used Flutter SDK version (e.g. `stable`) you should call the Flutter SDK command as you would normally do in case of typical Flutter installation. See more in the section [Running Flutter SDK commands](#running-flutter-sdk-commands). - -```bash -> fvm flutter upgrade -``` - -### List Installed Versions - -List all the versions that are installed on your machine. This command will also output where FVM stores the SDK versions. - -```bash -> fvm list -``` - -### List Flutter Releases - -Displays all Flutter releases, including the current version for `dev`, `beta` and `stable` channels. - -```bash -> fvm releases -``` - -## Running Flutter SDK commands - -There are couple of ways you can interact with the Flutter SDK setup in your project. You can run all the Flutter commands through the fvm _proxy commands_. - -### Proxy Commands - -The `flutter` and `dart` commands within `fvm` proxy all calls to the CLI just changing the SDK to be the local one. - -For instance, to run the `flutter run` with a given Flutter SDK version just call the following. FVM will recursively try for a version in a parent directory. - -```bash -> fvm flutter run -``` - -This syntax works also for commands with parameters. The following command will call `flutter build` for a selected flavor and target. - -```bash -> fvm flutter build aab --release --flavor prod -t lib/main_prod.dart -``` - -In other words, calling a `fvm flutter xxx` command is equivalent to `flutter xxx` if `fvm` is available in the directory tree. - -### Call Local SDK Directly - -You can also call the local SDK directly bypassing the _proxy commands_. FVM creates a symbolic link within your project called **fvm** which links to the installed version of the SDK. - -```bash -> .fvm/flutter_sdk/bin/flutter run -``` - -The above example is equivalent to `flutter run` command using the local project SDK. - -### Change FVM Cache Directory - -You are able to configure the **fvm** cache directory by setting `FVM_HOME` environment variable. If nothing is set the default **fvm** path will be used. You are also able to change the directory by setting the `--cache-path` on the config. See below - -### FVM Config - -There are some configurations which you are able to set on FVM. **All settings set on CLI are compatible with the App(GUI)**. - -#### List config - -```bash -> fvm config -``` - -#### Set cache path - -Location where Flutter SDK versions will be stored. If nothing is set, default will be used. - -```bash -> fvm config --cache-path -``` - -### Flutter Fork & Git Cache - -You are able to use your own Flutter fork or cache the Flutter git locally for faster cloning, by setting the `FVM_GIT_CACHE` environment variable. - -## Configure Your IDE - -In some situations you might have to restart your IDE and the Flutter debugger to make sure it uses the new version. - -### VSCode - -Add the following to your `settings.json`. This will list all Flutter SDKs installed when using VSCode when using `Flutter: Change SDK`. - -Use `fvm list` to show you the path to the versions. - -#### List all versions installed by FVM - -You can see all the versions installed by FVM in VS Code by just providing path to `versions` directory: - -```json -{ - "dart.flutterSdkPaths": ["/Users/usr/fvm/versions"] -} -``` - -Alternatively, you can specify only selected versions. The following snippet will cause VS Code to show only `stable` and `dev` versions of Flutter. - -```json -{ - "dart.flutterSdkPaths": [ - "/Users/usr/fvm/versions/stable", - "/Users/usr/fvm/versions/dev" - ] -} -``` - -To change current Flutter version open a project and select `Flutter: Change SDK` in the command palette. You should see all the versions as depicted in the following screenshot. - -![VS Code version selector screenshot](./assets/vs_code_versions.png?raw=true "VS Code version selector screenshot") - -#### You can also add the version symlink for dynamic switch - -```json -{ - "dart.flutterSdkPath": ".fvm/flutter_sdk" -} -``` - -#### Remove the flutter sdk from search to make things easier - -```json -{ - "search.exclude": { - "**/.fvm": true - } -} -``` - -### Android Studio - -Copy the **_absolute_** path of fvm symbolic link in your root project directory. Example: `/absolute/path-to-your-project/.fvm/flutter_sdk` - -In the Android Studio menu open `Languages & Frameworks -> Flutter` or search for Flutter and change Flutter SDK path. Apply the changes. You now can Run and Debug with the selected versions of Flutter. -Restart Android Studio to see the new settings applied. - -[Add your IDE instructions here](https://github.com/leoafarias/fvm/issues) +[![FVM App Screenshot](https://raw.githubusercontent.com/leoafarias/sidekick/main/assets/screenshot.png)](https://github.com/leoafarias/sidekick) ## Working with this repo diff --git a/lib/src/models/settings_model.dart b/lib/src/models/settings_model.dart index 1d3973eb..0d146e9d 100644 --- a/lib/src/models/settings_model.dart +++ b/lib/src/models/settings_model.dart @@ -29,8 +29,8 @@ class FvmSettings { factory FvmSettings.fromMap(Map map) { return FvmSettings( cachePath: map['cachePath'] as String?, - skipSetup: map['skipSetup'] as bool, - gitCache: map['gitCache'] as bool, + skipSetup: map['skipSetup'] as bool? ?? false, + gitCache: map['gitCache'] as bool? ?? false, ); } diff --git a/lib/src/version.dart b/lib/src/version.dart index 0e58df39..6884ff88 100644 --- a/lib/src/version.dart +++ b/lib/src/version.dart @@ -1,2 +1,2 @@ // Generated code. Do not modify. -const packageVersion = '2.0.0'; +const packageVersion = '2.0.1'; diff --git a/pubspec.yaml b/pubspec.yaml index a3a8fef7..74bc4716 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: fvm description: A simple cli to manage Flutter SDK versions per project. Support channels, releases, and local cache for fast switching between versions. -version: 2.0.0 +version: 2.0.1 homepage: https://github.com/leoafarias/fvm environment: