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

Cannot run example app from pub.dev #65

Open
BenShelbourne opened this issue Aug 15, 2021 · 3 comments
Open

Cannot run example app from pub.dev #65

BenShelbourne opened this issue Aug 15, 2021 · 3 comments

Comments

@BenShelbourne
Copy link

I am trying to run the example found here but when I run it I get the following error.

The following _CastError was thrown attaching to the render tree:
type '(MethodCall) => Null' is not a subtype of type '((MethodCall) => Future<dynamic>)?' in type cast

What is the fix for this?

@fxia86
Copy link

fxia86 commented Aug 15, 2021

the same issue.

pubspec.yaml
environment:
sdk: ">=2.10.0 <3.0.0" works well

environment:
sdk: ">=2.12.0 <3.0.0" will throw the exception below

════════ Exception caught by widgets library ═══════════════════════════════════
The following _CastError was thrown building Builder:
type '(MethodCall) => Null' is not a subtype of type '((MethodCall) => Future<dynamic>)?' in type cast

The relevant error-causing widget was
GestureDetector
lib\main.dart:29
When the exception was thrown, this was the stack
#0      new BluetoothPrint._
package:bluetooth_print/bluetooth_print.dart:26
#1      BluetoothPrint._instance
package:bluetooth_print/bluetooth_print.dart:29
#2      BluetoothPrint._instance (package:bluetooth_print/bluetooth_print.dart)
package:bluetooth_print/bluetooth_print.dart:1
#3      BluetoothPrint.instance
package:bluetooth_print/bluetooth_print.dart:31
#4      new _PrinterManagePageState
package:bubble_tea/…/printer/printer_manage_page.dart:44
...
════════════════════════════════════════════════════════════════════════════════

@BenShelbourne
Copy link
Author

@thon-ju are there any plans to migrate to 2.12 ?

@tranthanhvu
Copy link

tranthanhvu commented Aug 19, 2021

I have to modify the constructor to fix it
From

  BluetoothPrint._() {
    _channel.setMethodCallHandler((MethodCall call) {
      _methodStreamController.add(call);
      return;
    } as Future<dynamic> Function(MethodCall)?);
  }

To

  BluetoothPrint._() {
    _channel.setMethodCallHandler((MethodCall call) async {
      _methodStreamController.add(call);
    } as Future<dynamic> Function(MethodCall)?);
  }

environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
bluetooth_print: ^3.0.1

tranthanhvu added a commit to tranthanhvu/bluetooth_print that referenced this issue Aug 19, 2021
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

3 participants