Dependency Issues in Flutter
Dependencies in Flutter are packages that are required in order for the project to function and are
listed in pubspec file. Dependency issues in flutter arise when two or more package require a given
dependency but with different versions, due to the difference in version, flutter cannot make the
decision on which version dependency o use and the issue arises.
Resolving Dependency Issues in Flutter
To resolve these kinds of conflicts in flutter, we can remove version numbers from the conflict-
causing dependencies and write any and the flutter program will make the decision on which
version is best suited for our project. Furthermore, we can add dependency_overrides which will
temporarily override all dependencies. Th flutter dependency issue problem can be solved as well
as avoided by following :
• Using any keyword in place of version number for packages causing the issue which will
allow flutter to select the version.
• Using dependency_overrides in pubsec file for a temporary solution.
• Using packages that are stable and up to date.
• Using caret syntax to indicate the range of version numbers.
Examples of Dependency Issues
Here, the issue is because many of the packages such as mockito, test_api depend on different
versions of flutter_places_autocomplete.
The issue is solved when version numbers are added for different packages except for mockito
and test_api and the keyword any is added in place of version number for them.
Another example of dependency conflict
Here, the issue is because graphql and flutter_bloc both depends on rxdart but of different versions.
Graphql depends on rxdart:^0.22.0 whereas flutter_block deonds on rxdart:^0.23.0
It can be solved by overriding dependency or using any keyword in place of version name beside
package name.