Managing Flutter Versions for Your App

Managing Flutter Versions for Your App

Working with the Flutter Version Manager

·

4 min read

Table of contents

Introduction

In the fast-paced world of mobile app development, staying up-to-date with the latest technologies and frameworks is essential. Flutter, Google's open-source UI software development kit, has gained tremendous popularity among developers for building cross-platform applications with remarkable speed and efficiency. With its vibrant community and continuous evolution, Flutter brings numerous improvements and updates with each new version.

However, managing different versions of Flutter across multiple projects can quickly become a daunting task. Different projects may have specific dependencies or requirements, and coordinating these variations manually can lead to complications and inefficiencies in the development workflow. This is where a powerful tool known as the Flutter Version Manager (FVM) steps in.

The Flutter Version Manager offers developers a streamlined and hassle-free approach to managing multiple Flutter SDK versions effortlessly. Whether you need to work on a project using an older Flutter release or want to experiment with the latest features of the newest version, FVM simplifies the process by providing a centralized and flexible environment.

In this article, we will delve into the world of Flutter Version Manager, exploring its key features, benefits, and how it can empower developers to efficiently manage their Flutter projects. We will discuss the installation process, showcase essential commands, and highlight real-world scenarios where FVM can make a significant impact on your Flutter development journey.

By adopting the Flutter Version Manager, developers can seamlessly switch between Flutter versions, maintain project-specific dependencies, collaborate with teams effectively, and ensure project stability. Additionally, we will explore the robust ecosystem surrounding FVM, including integrations with popular editors and continuous integration (CI) platforms.

Whether you are an experienced Flutter developer seeking better project management or a newcomer curious about efficient development workflows, this article will provide you with valuable insights and practical knowledge on how the Flutter Version Manager can revolutionize your Flutter development experience.

So, let's embark on a journey of simplified Flutter version management, empowering you to take your mobile app development to new heights with confidence and ease.


Step 1: To Install fvm run the command in terminal

dart pub global activate fvm

To test fvm is successfully installed or not, run this command

fvm --version //output-->> 2.3.1

Step 2: To check the list of flutter versions install, run this command

fvm list

the output can be as follows

Step 3: To install the Flutter version

1. fvm install 3.7.2
2. cd path/to/project
3. fvm use 3.7.2

A folder named .fvm is created in your project with the version you want to use.

Step 4: Setup VS Code to use fvm
Create a file in .vcode file named settings.json. To create a file run the command touch .vscode/settings.json in the root of your project & paste the code given below.

{
    "dart.flutterSdkPath": ".fvm/flutter_sdk",
    // Remove .fvm files from search
    "search.exclude": {
        "**/.fvm": true
    },
    // Remove from file watching
    "files.watcherExclude": {
        "**/.fvm": true
    }
}

"dart.flutterSdkPath": ".fvm/flutter_sdk": This sets the path to the Flutter SDK used by the development environment. The path is set to .fvm/flutter_sdk, which indicates that the SDK is installed using a package manager called FVM (Flutter Version Management).

"search.exclude": { "**/.fvm": true }: This setting excludes all files and directories under the .fvm directory from the search results. This is useful to avoid cluttering the search results with system-generated files that are not relevant to the project.

"files.watcherExclude": { "**/.fvm": true }: This setting excludes all files and directories under the .fvm directory from file watching. This is useful to reduce the amount of CPU and memory resources used by the development environment when watching for changes in the project files.

Step 4: If you want to run, add packages in the Project from the terminal, then you have to add fvm in the command as shown below.

fvm flutter run
fvm flutter pub add styled_widget

Step 5: having to run all commands with fvm before them can be a daunting task. How about we do it the usual way while still using FVM. To be able to do that we will need to set up fvm globally:

fvm global 3.10.5

Conclusion:

Depending on your needs and preferences switching between different versions of Flutter can be a smooth and efficient process. In the next article, I will tackle how to do it without third-party tools like fvm.