Flutter_svg: Error: Type 'DiagnosticableMixin' not found

Created on 24 Jun 2020  Âˇ  33Comments  Âˇ  Source: dnfield/flutter_svg

Pub/Cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:88:26: Error: Type 'DiagnosticableMixin' not found.
class PictureStream with DiagnosticableMixin {
^^^^^^^^^^^^^^^^^^^
Pub/Cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:192:44: Error: Type 'DiagnosticableMixin' not found.
abstract class PictureStreamCompleter with DiagnosticableMixin {
^^^^^^^^^^^^^^^^^^^
Pub/Cache/hosted/pub.dartlang.org/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 {
^
Pub/Cache/hosted/pub.dartlang.org/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 {
^
Pub/Cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:167:11: Error: Superclass has no method named 'debugFillProperties'.
super.debugFillProperties(properties);
^^^^^^^^^^^^^^^^^^^
Pub/Cache/hosted/pub.dartlang.org/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' ('Pub/Cache/hosted/pub.dartlang.org/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(),
    ^^^^^^^^^^^^^
    Pub/Cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:266:11: Error: Superclass has no method named 'debugFillProperties'.
    super.debugFillProperties(description);
    ^^^^^^^^^^^^^^^^^^^
    Why do not you leave at least one past version working, because when you try to downgrade a similar error occurs? What is the problem? Yes I know your answer “that upgrade to version 0.18.0 and it will work”, but even this is not possible now. Make at least one assembly that will work for any of your changes, I beg.

Most helpful comment

There are two ways to solve it, if you are in an older version of flutter other than the last one (1.20), you can either use the version flutter_svg: 0.17.4 or if any of the other packages uses 0.18 you can override it like this :

dependency_overrides:
   flutter_svg: ^0.17.4

But if it is in the latest version of flutter this will not work, you have to use 0.18 and override for the last version 2 libs thatflutter_svg uses, which are image andxml, then something like this :

dependencies:
  ...
   flutter_svg: ^0.18.0
   ...

dependency_overrides:
  image: last_version
  xml: last_version

This for me works, you can try.

All 33 comments

Same here

Can you post a flutter --version? In flutter 1.17.4 stable channel and flutter_svg 0.17.4 this does not happen

There are a number of issues being raised like this one.

Here's the high level explanation:

  • Flutter has gone through a cycle of refactoring the Diagnosticable class(es).
  • Flutter does not meaningfully use semver, and never will. There are good reasons for this, but it makes things confusing sometimes.
  • This package does not specify a meaningful upper bound constraint on Flutter - like most packages on pub. It's hard to do in part becuse Flutter doesn't use semver.

So - if you're seeing _this_ error, you need to use flutter_svg v0.18.0+.

If you're using flutter_svg v0.18.0 and seeing a _different error about how you can't use a mixin_, you need to use flutter_svg v0.17.4 or lower.

There are two ways to solve it, if you are in an older version of flutter other than the last one (1.20), you can either use the version flutter_svg: 0.17.4 or if any of the other packages uses 0.18 you can override it like this :

dependency_overrides:
   flutter_svg: ^0.17.4

But if it is in the latest version of flutter this will not work, you have to use 0.18 and override for the last version 2 libs thatflutter_svg uses, which are image andxml, then something like this :

dependencies:
  ...
   flutter_svg: ^0.18.0
   ...

dependency_overrides:
  image: last_version
  xml: last_version

This for me works, you can try.

Or you can go to picture_stream.dart and replace all DiagnosticableMixin with Diagnosticable

@egorikem just note that pub expects you to never modify your pub cache - if you do that, it will not pull in a fresh version when you do pub get in the future, even in another project, and once you roll to the latest version of the Flutter framework you will get errors until you go back and undo the changes in your pub cache.

Also, it should go without saying, but there's no revision tracking of the files in the pub cache.

I have the same error message after upgrading Flutter. I use flutter_html: ^1.0.0 which depends on flutter_svg ^0.17.4, so I could not update flutter_svg in pubspec.yaml. So how should I fix this error?

There are two ways to solve it, if you are in an older version of flutter other than the last one (1.20), you can either use the version flutter_svg: 0.17.4 or if any of the other packages uses 0.18 you can overwrite it like this :

dependency_overrides:
   flutter_svg: ^ 0.17.4

But if it is in the latest version of flutter this will not work, you have to use 0.18 and overwrite for the last version 2 libs thatflutter_svg uses, which are image andxml, then something like this :

dependencies:
  ...
   flutter_svg: ^ 0.18.0
   ...

dependency_overrides:
  image: last_version
  xml: last_version

This for me works, you can try.

installing flutter_svg: ^ 0.17.4 worked for me. Thanks :)

@Aoi-hosizora I have the same issue. Were you able to solve this?

@zanesc As for me, dependency_overrides can solve this problem. See https://github.com/Sub6Resources/flutter_html/issues/351#issuecomment-657086837

@Aoi-hosizora thank you that worked for me.

Just updated to the latest Flutter version because VSCode suggested it... worst mistake ever.

Just updated to the latest Flutter version because VSCode suggested it... worst mistake ever.

I had also done the same.

I had to do this as suggested by egorikem earlier -
"Or you can go to picture_stream.dart and replace all DiagnosticableMixin with Diagnosticable"

And also had to add the below in the pubspec.yaml to make it work -

dependencies:
flutter_svg: ^0.18.0

dependency_overrides:
flutter_svg: ^0.17.4

If you get this error, you are using the wrong version of flutter_svg for your version of Flutter. You need to downgrade flutter_svg to v0.17.4 or upgrade flutter to the minimum constraint expected by v0.18.0.

There are two ways to solve it, if you are in an older version of flutter other than the last one (1.20), you can either use the version flutter_svg: 0.17.4 or if any of the other packages uses 0.18 you can override it like this :

dependency_overrides:
   flutter_svg: ^0.17.4

But if it is in the latest version of flutter this will not work, you have to use 0.18 and override for the last version 2 libs thatflutter_svg uses, which are image andxml, then something like this :

dependencies:
  ...
   flutter_svg: ^0.18.0
   ...

dependency_overrides:
  image: last_version
  xml: last_version

This for me works, you can try.

@dnfield
What do I write here in last_version?

What do I write here in last_version?

Go to pub.dev and see the latest version of these plugins available

use this

dependencies:
  flutter_svg: ^0.18.0

dependency_overrides:
  flutter_svg: ^0.17.4

and throw exception yet:

Running "flutter pub get" in driving_car...
Warning: You are using these overridden dependencies:
! flutter_svg 0.17.4
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:88:26: Error: Type 'DiagnosticableMixin' not found.
class PictureStream with DiagnosticableMixin {
                         ^^^^^^^^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:192:44: Error: Type 'DiagnosticableMixin' not found.
abstract class PictureStreamCompleter with DiagnosticableMixin {
                                           ^^^^^^^^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/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 {
      ^
../../flutter/.pub-cache/hosted/pub.dartlang.org/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 {
               ^
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.17.4/lib/src/picture_stream.dart:167:11: Error: Superclass has no method named 'debugFillProperties'.
    super.debugFillProperties(properties);
          ^^^^^^^^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/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' ('../../flutter/.pub-cache/hosted/pub.dartlang.org/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(),
                             ^^^^^^^^^^^^^
../../flutter/.pub-cache/hosted/pub.dartlang.org/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.

* Where:
Script '/Users/tanyi/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 896

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/Users/tanyi/flutter/bin/flutter'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 18s
Exception: Gradle task assembleDebug failed with exit code 1

my version is:

Flutter 1.20.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 2ae34518b8 (25 hours ago) • 2020-08-05 19:53:19 -0700
Engine • revision c8e3b94853
Tools • Dart 2.9.0

@parcool Flutter 1.20.1 works fine with flutter_svg 1.18.0.
Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 1.20.1, on Linux, locale en_US.UTF-8) [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3) [✓] Android Studio (version 4.0) [✓] Connected device (1 available)
I just run after upgrade/update
flutter clean

dependency_overrides:
  flutter_svg: ^0.18.0

@function1983 fixed.thanks!

I updated Flutter and that problem appeared. I was not using flutter_svg (directly) but maybe another library was, so I added flutter_svg: ^0.18.0 to my pubspec.yaml and the problem dissapeared.

I upgrade to 1.20.1 and get stuck with this lib flutter_cupertino_date_picker: ^1.0.26+2

if you use flutter_cupertion_date_picker there seems to be a problem on the package
https://pub.dev/packages/flutter_cupertino_date_picker/score
image

Updating flutter_html version to 1.0.2 solved it for me

There are two ways to solve it, if you are in an older version of flutter other than the last one (1.20), you can either use the version flutter_svg: 0.17.4 or if any of the other packages uses 0.18 you can override it like this :

dependency_overrides:
   flutter_svg: ^0.17.4

But if it is in the latest version of flutter this will not work, you have to use 0.18 and override for the last version 2 libs thatflutter_svg uses, which are image andxml, then something like this :

dependencies:
  ...
   flutter_svg: ^0.18.0
   ...

dependency_overrides:
  image: last_version
  xml: last_version

This for me works, you can try.

My version is 1.20.0 and flutter_svg: ^0.18.0 worked for me
Thank you

To solve this is done the following updates in pubspec.yaml
Flutter_svg: ^0.18.0
flutter_html: ^1.0.2
flutter_widget_from_html: 0.4.3

After a Dart and Flutter upgrade, same problem.
This worked for me, was being used in another package. (Remember to add spaces don't know why it copies this way on here)
Also don't know why both dependencies and overrides has the same version in my solution.
Wil do my research.

dependency_overrides:
  flutter_svg: ^0.18.0

dependencies:
  flutter_svg: ^0.18.1

Solved on 1.20.2 using this.

Or you can go to picture_stream.dart and replace all DiagnosticableMixin with Diagnosticable

Saved me!
With Flutter v1.20.3 stable and flutter_svg v1.18.0

I got this because i have used flutter_html : 1.0.0 and flutter_html : 1.0.0 is dependent on flutter_svg : 0.17.4 or lower

So i just updated flutter_html : 1.0.2 in my project and it worked for me...

just change from flutter_svg: ^0.17.4 to flutter_svg: ^ 0.18.0

Replacing ‘with DiagnosticableMixin’ or change 'DiagnosticableMixin' to 'Diagnosticable' and it works well for me.

Replacing ‘with DiagnosticableMixin’ or change 'DiagnosticableMixin' to 'Diagnosticable' and it works well for me.

that's work form e to. thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

coupestartup picture coupestartup  Âˇ  6Comments

ChristianKleineidam picture ChristianKleineidam  Âˇ  5Comments

lennartschoch picture lennartschoch  Âˇ  4Comments

kentcb picture kentcb  Âˇ  4Comments

vanlooverenkoen picture vanlooverenkoen  Âˇ  5Comments