简体   繁体   中英

Roll back dart-sdk in flutter cache

I wrote a flutter app about an year ago. It was working fine and I was able to release it for testing as well. In the app I was using a number of various different packages to perform different things such as: pick a file, view images etc. The most important package that I was using were

tflite_flutter: 0.5.0
tflite_flutter_helper: 0.1.2

Besides above I had following in my app:

environment:
 sdk: ">=2.7.0 <3.0.0"

and in the build.gradle file:

compileSdkVersion 29
buildToolsVersion "29.0.2"
...
targetSdkVersion 29

Recently I decided to add Firebase Realtime Database to the app just for "fun". So I included the following package:

firebase_database: ^9.0.4

But after adding it my app failed to compile and I saw messages suggesting me to update the dependent package. I carried this out one package after the other in order to resolve the errors. Eventually I reached a point where I ended up updating my android versions to 32, installing the v32 build tools and sdk to satisfy the dependency issues. My app compiled but when I ran the app the tensorflow model failed to load. It was at this point where after looking up the error messages I decided to increase the min version of flutter to 2.12. But then it appeared that I have to update all my code with "late" and other stuff which I have not yet figured out and did not want to spend time on. So, I decided to do git stash. I would have thought that this rolled back everything and I would be able to get the old working state back but for some odd reason I am unable to compile the app. Here is one of the errors that I see:

/apps/flutter/.pub-cache/hosted/pub.dartlang.org/filesystem_picker-1.0.3/lib/src/picker_page.dart:187:63: Error: The getter 'title' isn't defined for the class 'TextTheme'. - 'TextTheme' is from 'package:flutter/src/material/text_theme.dart' ('/C:/apps/flutter/packages/flutter/lib/src/material/text_theme.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'title'.
                color: AppBarTheme.of(context).textTheme?.title?.color ??

All of the information that I was able to dig out point me to updating the flutter version and version of other stuff which I don't want. I would like to be able to compile it once again as it was compiling before all the changes. I feel it has something to do with the following:

  • flutter version (I have now reset it to what it was before but I am not sure about the version of dart)
  • android build tools. Even though the version specified in gradle file is restored to the previous one but I have not uninstalled v32 yet.
  • or something else?

Q. How do I get back to the old state after all these updates, what other steps should I take in order to properly roll back?

UPDATE I notice that bin/cache/dart-sdk has a very recent timestamp. It appears that flutter might have updated the dart version when I ran upgrade. After that I can't find a way to use a previous version of dart. I tried to manually download it and place it in the cache but it does not pick it up. Is there a way to force flutter to use a specific version of dart-sdk?

The dart-sdk got updated after I ran flutter upgrade . To roll it back I had to just run flutter downgrade and it automatically rolls back to last installed version. For some reason search for flutter downgrade on google does not lead to a clear answer or the flutter docs. There are answers which refer to providing a version a number but in my case I did not remember the version I was working with. In the documentation for flutter cli there is a one line description for this command:

downgrade   flutter downgrade   Downgrade Flutter to the last active version for the current channel.

https://docs.flutter.dev/reference/flutter-cli

Here are some of the things that I learned after going through the above:

  1. flutter downgrade does not accept a version number argument as suggested in several articles.
  2. flutter ships with a tightly coupled version of dart. The users can't change that.
  3. flutter/bin/cache/dart-sdk -> this is the install location of flutters dart-sdk. I tried replacing it but flutter downloads the version it needs automatically.
  4. If you are working on a code base that was last touched in early 2021 (one year ago) then be prepared to face several breaking changes and finding alternates to packages that are no longer supported if you want to update flutter.
  5. Prefer packages created by flutter or a company as these have more chances to stay up to date.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM