Skip to content

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

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

Closed
andresgd7 opened this issue Jul 23, 2024 · 8 comments
Closed

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.

@Guziq
Copy link

Guziq commented Oct 24, 2024

The error was resolved in 0.11.0, so I guess this can be closed.

@andresgd7
Copy link
Author

Thanks everyone for the answers, this will be closed now.

@charlieforward9
Copy link

charlieforward9 commented Nov 6, 2024

I am unable to bump from 0.9.5 because of dependency conflicts. The temporary change did not work as is... throwing:

Error: The getter 'tfliteBinding' isn't defined for the class 'Tensor'.

I had to remove the tfliteBinding object to get it to work.

/// Underlying data buffer as bytes.
Uint8List get data {
  final data = cast<Uint8>(tfLiteTensorData(_tensor));
  return data.asTypedList(tfLiteTensorByteSize(_tensor)).asUnmodifiableView();
}

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

7 participants