skip to Main Content

I just cloned a repository of a Flutter project and i dont know which flutter sdk version should i use. I tried with 5-6 version and every one of them threw a error (errors like "this function doesnt exist" or something like that.

I use the version 3.18.0-0.1.pre (since its says that in the pubspec.lock at the end, and with that version i was able to run the project, but i had to change the version of the package intl since it throw a error saying this:

Note: intl is pinned to version 0.18.1 by flutter_localizations from the flutter SDK.
See https://dart.dev/go/sdk-version-pinning for details.
2

Because every version of flutter_localizations from sdk depends on intl 0.18.1 and evita_mobile depends on intl ^0.19.0, flutter_localizations from sdk is forbidden.
So, because evita_mobile depends on flutter_localizations from sdk, version solving failed.

I was able to run the project but it doesnt work like it should work (i wasnt able to go more than the login page, since the functions to authenticate the user doenst work). And i think this is because it changed a lot of things in the pubspec.lock

At the moment, I don’t know if the problem is the version of Flutter, but this is my theory, since the previous programmer who left the company was able to run the project without problems.

Ah, and btw, i already tried a lot of terminal codes like flutter pub get, flutter pub outdated, flutter pub upgrade, flutter pub upgrade –major-versions and so more.

I will drop the pubspec.yaml here because i think its important:

name: evita_mobile
description: A new Flutter project.

version: 1.0.0+1

environment:
  sdk: ">=2.19.2 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.2
  http: ^0.13.4
  shared_preferences: ^2.0.15
  intl: ^0.19.0
  flutter_html: ^3.0.0-alpha.6
  encrypt: ^5.0.1
  file_picker: ^5.2.6
  mime: ^1.0.4
  path_provider: ^2.0.14
  syncfusion_flutter_pdfviewer: ^21.2.3
  flutter_barcode_scanner: ^2.0.0
  chewie_audio: ^1.5.0
  flutter_localizations:
    sdk: flutter
  dots_indicator: ^3.0.0
  font_awesome_flutter: ^10.5.0
  url_launcher: ^6.0.12
  table_calendar: ^3.0.9
  flutter_launcher_icons: ^0.13.1
  flutter_local_notifications: ^9.0.0
  permission_handler: ^10.4.5
  workmanager: ^0.5.2
  flutter_secure_storage: ^8.1.0
  flutter_inappwebview: ^5.5.0+5
  infinite_scroll_pagination: ^4.0.0

flutter_icons:
  image_path: "lib/images/evita_logo.png"
  android: true
  ios: true

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.0

flutter:
  uses-material-design: true
  assets:
    - lib/images/

I use the version 3.18.0-0.1.pre (since its says that in the pubspec.lock at the end, and with that version i was able to run the project, but i had to change the version of the package intl since it throw a error.

I was able to run the project but it doesnt work like it should work (i wasnt able to go more than the login page, since the functions to authenticate the user doenst work). And i think this is because it changed a lot of things in the pubspec.lock

2

Answers


  1. If you can open the pubspec.lock file you will be able to see the flutter and dart version at the bottom of file. There you can compare it with your’s version.

    Remove dependency issues you can check for outdated packages in pubspec.yaml file or by running command in Terminal. And then run flutter pub upgrade --major-versions to upgrade the packages to latest relevant versions. It may help to sort your issue.

    Login or Signup to reply.
  2. What it seems to happen here, is that your project is not updated with the latest Flutter version.

    Yes, you could manage and run it by finding the Flutter version you need to use by going to the pubspec.lock (as written by the other answer here), but I would recomment you to take the time and slowly upgrade the project.

    If not, sooner or later you will need to continuously change Flutter versions between different projects, or be forced to update by either Flutter or a Package.

    If it’s just one file as the above, and the dev of the package has not updated in months, either find another package, or you could fork it and update it yourself (and import your version as package). But before doing that, do read the bellow because forking and using your own package is like the last solution you should go for.

    Oh and also very important: do not edit manually your pubspec.lock!!! It’s an auto generated file.

    How to update your Flutter project

    Upgrate Flutter and Packages versions

    What updating the project means, is to have your Flutter and packages versions to their newest, compatible with each other, versions. To do that, you need to upgrade your Flutter version to the latest stable one, and then all your packages to their newest version on their package page.

    Resolve Packages conflicts

    Then there are two scenarios, either pub get will run smoothly, or you’ll get an error as the above you write – but for in-between packages. Then you’ll have to downgrade the package with the larger version at the error, and continue this process till pub get runs correctly. Quite a hideous process, but necessary – and it can get a bit advanced if the project is too old.

    Resolve Flutter code conflicts

    Then, if pub get runs without issues, you will need to resolve code conflicts. As you mentioned above, you got errors like "this function does not exists" – I suspect that was because your project has such an older version of Flutter that it uses now depricated functions.

    What you need to do in this situation, is to search each different function to google asking with which flutter function it has been replaced – and use that one.

    It can be scary to make such changes if you are new to Flutter, but if you take it slow and steady, you have nothing to be afraid so.

    That’s it!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search