Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The method 'UnmodifiableUint8ListView' isn't defined for the class 'Tensor'. #232

Open
andresgd7 opened this issue Jul 23, 2024 · 5 comments

Comments

@andresgd7
Copy link

andresgd7 commented Jul 23, 2024

Im using tflite_flutter-0.10.4 but UnmodifiableUint8ListView was deprecated from typed_data some while ago:
image

https://api.dart.dev/stable/2.13.4/dart-typed_data/dart-typed_data-library.html

When i try to run my code in android i get this:

../../../../AppData/Local/Pub/Cache/hosted/pub.dev/tflite_flutter-0.10.4/lib/src/tensor.dart:58:12: Error: The method 'UnmodifiableUint8ListView' isn't defined for the class 'Tensor'.
 - 'Tensor' is from 'package:tflite_flutter/src/tensor.dart' ('../../../../AppData/Local/Pub/Cache/hosted/pub.dev/tflite_flutter-0.10.4/lib/src/tensor.dart').
Try correcting the name to the name of an existing method, or defining a method named 'UnmodifiableUint8ListView'.
    return UnmodifiableUint8ListView(

any fix?

@ptgms
Copy link
Contributor

ptgms commented Jul 24, 2024

I have a temporary fix until it is fixed in the package. Change the package locally in your pub-cache.
In the conflicting line, change the getter to this:

Uint8List get data {
    final data = cast<Uint8>(tfliteBinding.TfLiteTensorData(_tensor));
    return data.asTypedList(tfliteBinding.TfLiteTensorByteSize(_tensor)).asUnmodifiableView();
  }

That worked for me :)

@andresgd7
Copy link
Author

Thanks bro!

@mehdigriche
Copy link

@ptgms I have shared your response on stack : https://stackoverflow.com/questions/78789213/the-method-unmodifiableuint8listview-isnt-defined-for-the-class-tensor/78842046#78842046

@AntoineChauviere
Copy link

Thank you very much! Do you know how to use tflite_flutter_helper with this version of tflite_flutter? It seems like this helper library might be deprecated, but it was very useful for image processing.

@CaptainDario
Copy link
Contributor

Commit abac02b seems to fix this, only a new version of this package is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants