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

Dart 2 invokeMethod compatibility #51

Closed
xqwzts opened this issue Mar 17, 2018 · 5 comments
Closed

Dart 2 invokeMethod compatibility #51

xqwzts opened this issue Mar 17, 2018 · 5 comments
Assignees

Comments

@xqwzts
Copy link

xqwzts commented Mar 17, 2018

With the upcoming Dart 2 changes we will run into errors when returning anything other than Future<dynamic> from invokeMethod calls.

Calls like:

Future<bool> get isOn => _channel.invokeMethod('isOn');

Need to be updated to:

Future<bool> get isOn async {
 final bool isOn = await _channel.invokeMethod('isOn');
 return isOn;
}

More details in this issue: flutter/flutter#15654

@staadecker
Copy link

Seems like this is not fully finished. The flutterBlue.isAvailable and flutter.isOn methods still throw errors

@staadecker
Copy link

I can submit a pull request but I need to know what is best practice (probably option 1).

Option 1
As @xqwzts recommands in his comment

Option 2
Simply change the return type from Future<bool> to Future

Thanks in advance!

@itavero
Copy link

itavero commented Oct 8, 2018

I think this issue needs to be reopened, as I am still getting errors when using isOn or isAvailable in v0.4.0.

@staadecker
Copy link

staadecker commented Oct 8, 2018

After more thought I think option 1 (from @xqwzts) is better since it doesn't change the method signature. I will submit a pull request when I have a moment.

@staadecker
Copy link

I submitted a pull request to fix. See issue #122 and pull request #123

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

4 participants