Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Setup detectors to be called with options #652

Merged
merged 10 commits into from
Jul 16, 2018

Conversation

bparrishMines
Copy link
Contributor

@bparrishMines bparrishMines commented Jul 9, 2018

Also removed close method to simplify implementation of detectors for version 0.0.2. On android, the api includes the close method, but not calling it doesn't seem to affect performance. Current implementation just initializes a new detector with options each time. This is easier for now since I'm working with an other developers who have already created an mlkit plugin. #646

Copy link
Contributor

@mravn-google mravn-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

case "TextDetector#close":
TextDetector.instance.close(result);
image = filePathToVisionImage((String) call.argument("path"), result);
if (image != null) TextDetector.instance.handleDetection(image, null, result);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears brittle. result must be called exactly once, but the code here does not enforce that on its own. Relying on another method to call result iff it returns null makes it easy to introduce an error later on.

public void close(MethodChannel.Result result) {}
public void handleDetection(
FirebaseVisionImage image,
@Nullable Map<String, Object> options,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sending a null map instead of the empty one is somewhat of an anti-pattern.

@bparrishMines bparrishMines merged commit 2251a22 into flutter:master Jul 16, 2018
@bparrishMines bparrishMines deleted the with_options branch July 16, 2018 18:46
kmorkos pushed a commit to kmorkos/plugins that referenced this pull request Jul 19, 2018
julianscheel pushed a commit to jusst-engineering/plugins that referenced this pull request Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants