Removing a Flutter Package: Step-by-Step Guide

Pushpam Saxena
2 min readMay 24, 2023

--

Image source: https://technobrains.io/why-your-next-mobile-app-should-be-made-in-flutter/

You might wonder why this blog post is necessary when removing Flutter packages seems like one of the first things a developer learns. However, as you delve deeper into the intricate world of Flutter, you’ll uncover hidden nuances. How hard you try to fix the version it doesn’t help.

Despite your best efforts, your application continues to access the outdated version you believed was removed simply by deleting the package declaration from pubspec.yamland running flutter pub getagain. Even version locking doesn’t work.

First, let’s understand the circumstances under which you would need to perform this action:

  • After updating the package version, you discovered that the new package has caused issues and disrupted previous functionalities. As a result, you now desire to revert back to the previous version.
  • Your application was working fine in the morning but now it’s showing some error and you don’t know why it happened.

Let’s see how you can solve this problem:

  • First, remove the package with flutter pub remove {package_to_be_removed}
  • Now navigate to .pub-cache/hosted directory. Generally, this directory is present at the user-level directories.
  • There are two folders present at this path pub.dartlang.organd pub.dev
There will be two folders at this location
  • Navigate to both directories and remove the package folder, using rm command
  • Now in the terminal run flutter pub add {package_to_be_added}:{package_version_to_be_added}

This should resolve the package dependency issues.

Go ahead and give it a whirl!

If it works it works otherwise it’s time to do what every self-respecting developer does: embark on an epic quest to consult the sacred texts of Google!

--

--

Pushpam Saxena
Pushpam Saxena

No responses yet