Ahmad Hassan
Ahmad Hassan

Reputation: 588

How to force flutter to use a old version of dependency?

After migration on flutter 1.17 application wont build. Circular check box is causing a error because with the migration on flutter 1.17 it is upgraded to 1.0.2 and even though i am using 1.0.1 in my app flutter still takes it as 1.0.2 and its causing trouble. Link to github issues This clears what my problem is and what's the solution but i don't know how to force or degrade a version. Changing the version in yaml isn't working. I've also tried using dependency_overrides: 1.0.1 but still error. enter image description here

Upvotes: 6

Views: 18911

Answers (2)

Christopher Moore
Christopher Moore

Reputation: 17123

You can specify the specific version you want to use in your pubspec.yaml by not including a caret ^ before the version number as we usually do. See this for more information of selecting package versions.

An example for your use:

dependencies:
  package_name: '1.0.1'

You should then run flutter pub upgrade to ensure that the package that will be used updates, though this may be unecessary.

Upvotes: 26

Jay Dangar
Jay Dangar

Reputation: 3469

You can also use dependency_overrides to override dependency, with this you can use both the version of your dependency at once.

dependencies:
 package_name : latest_version

dependency_overrides:
 package_name : older_version

Upvotes: 10

Related Questions