After I upgrade Flutter to 1.20.0-3.0.pre.142, my project builds failed (see logs). I find that flutter_svg 0.17.4 is depended by flutter_html 1.0.0. I have found an issue related to this problem: https://github.com/dnfield/flutter_svg/issues/368, but it says to update flutter_svg to 0.18.0+. So how could I fix this problem?
Launching lib\main.dart on Google Nexus 5X Android 8 in debug mode...
/C:/Users/Windows%2010/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/flutter_svg-0.17.4/lib/src/picture_stream.dart:88:26: Error: Type 'DiagnosticableMixin' not found.
class PictureStream with DiagnosticableMixin {
^^^^^^^^^^^^^^^^^^^
/C:/Users/Windows%2010/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/flutter_svg-0.17.4/lib/src/picture_stream.dart:192:44: Error: Type 'DiagnosticableMixin' not found.
abstract class PictureStreamCompleter with DiagnosticableMixin {
^^^^^^^^^^^^^^^^^^^
/C:/Users/Windows%2010/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/flutter_svg-0.17.4/lib/src/picture_stream.dart:88:7: Error: The type 'DiagnosticableMixin' can't be mixed in.
class PictureStream with DiagnosticableMixin {
^
/C:/Users/Windows%2010/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/flutter_svg-0.17.4/lib/src/picture_stream.dart:192:16: Error: The type 'DiagnosticableMixin' can't be mixed in.
abstract class PictureStreamCompleter with DiagnosticableMixin {
^
/C:/Users/Windows%2010/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/flutter_svg-0.17.4/lib/src/picture_stream.dart:167:11: Error: Superclass has no method named 'debugFillProperties'.
super.debugFillProperties(properties);
^^^^^^^^^^^^^^^^^^^
/C:/Users/Windows%2010/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/flutter_svg-0.17.4/lib/src/picture_stream.dart:171:30: Error: The method 'toStringShort' isn't defined for the class 'PictureStreamCompleter'.
- 'PictureStreamCompleter' is from 'package:flutter_svg/src/picture_stream.dart' ('/C:/Users/Windows%2010/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/flutter_svg-0.17.4/lib/src/picture_stream.dart').
Try correcting the name to the name of an existing method, or defining a method named 'toStringShort'.
ifPresent: _completer?.toStringShort(),
^^^^^^^^^^^^^
/C:/Users/Windows%2010/AppData/Roaming/Pub/Cache/hosted/pub.flutter-io.cn/flutter_svg-0.17.4/lib/src/picture_stream.dart:266:11: Error: Superclass has no method named 'debugFillProperties'.
super.debugFillProperties(description);
^^^^^^^^^^^^^^^^^^^
FAILURE: Build failed with an exception.
You can do a dependency override by specifying this in your pubspec:
dependency_overrides:
flutter_svg: 0.18.0
It will get fixed when the next flutter stable gets released:
@ueman I see, now I have to use dependency_overrides and it works. So when next version is released, this will be fixed?
@Aoi-hosizora Hi, How did you resolve this issue? I am having the same issue. I tried adding dependency overrides but same issue. Can you share your pubsec?
@sparkidea-codecrab Here is my pubspec.yaml, I override dependency version (although it logs warning) and it works.
dependencies:
# ...
flutter_html: ^1.0.0
# ...
dependency_overrides:
flutter_svg: 0.18.0
And here is my generated pubspec.lock:
flutter_html:
dependency: "direct main"
description:
name: flutter_html
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.0.0"
flutter_svg:
dependency: "direct overridden"
description:
name: flutter_svg
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.18.0"
@Aoi-hosizora Do I also have to add flutter_svg: ^0.17.4 on dependencies section?
@sparkidea-codecrab No, flutter_html will dependent flutter_svg 0.17.4, and it will add to lock file automatically. So we have to override this version using dependency_overrides.
@Aoi-hosizora I just did the same, but not luck. Got this:
[learning_kart_app] flutter pub get
Running "flutter pub get" in learning_kart_app...
Because flutter_svg >=0.18.0 depends on xml ^4.1.0 and every version of flutter_test from sdk depends on xml 3.6.1, flutter_svg >=0.18.0 is incompatible with flutter_test from sdk.
So, because kart depends on both flutter_test any from sdk and flutter_svg 0.18.0, version solving failed.
pub get failed (1; So, because kart depends on both flutter_test any from sdk and flutter_svg 0.18.0, version solving failed.)
exit code 1
@Aoi-hosizora I resolved it.. thank you!
I have solved this problem temporarily using dependency_overrides. So I just close this issue.
Solved it by adding dependency_overides in pubspec.xml
dependency_overrides:
flutter_svg: 0.18.0
Most helpful comment
You can do a dependency override by specifying this in your pubspec:
It will get fixed when the next flutter stable gets released:
https://github.com/Sub6Resources/flutter_html/pull/332