Julien
Julien

Reputation: 21

Flutter - change current platform on unit test

I'm currently making unit tests for my app, and have a problem to test functions from packages made only for android & iOS (https://pub.dev/packages/google_mlkit_text_recognition).

I have a code which works when I use it on real device, but don't works in my unit test with the error : "MissingPluginException(No implementation found for method vision#startTextRecognizer on channel google_mlkit_text_recognizer)".

As I understand, the problem is that the package methods won't work on another platform than android / iOS. Is there a way to set platform to iOS during unit tests ? Already tried to modify the "defaultTargetPlatform", doesn't work.

Thanks, Julien

Created a unit test calling google_mlkit_text_recognition functions, which work on device, but not on unit tests.

Upvotes: 2

Views: 1053

Answers (1)

ziqq
ziqq

Reputation: 971

Try this

debugDefaultTargetPlatformOverride = TargetPlatform.iOS;

Upvotes: 2

Related Questions