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

第一次在释放生命周期的时候会提示 PdaScannerPlugin:onCancel; #9

Open
fanqienoodle opened this issue Jul 15, 2020 · 2 comments

Comments

@fanqienoodle
Copy link

Steps to Reproduce

1.当我首次初始化pda_scanner的时候,用扫码枪扫描是可以得到条码的信息的,但是当我离开页面的时候再次进入 扫描就没有反应了
import 'package:flutter/material.dart';
import 'package:pda_scanner/pda_source.dart';
import 'package:pda_scanner/pda_listener_mixin.dart';

class PdaScan extends StatefulWidget {
@OverRide
_PdaScanState createState() => _PdaScanState();
}

class _PdaScanState extends State with PdaListenerMixin {
var _code;
var _error;
@OverRide
void initState() {
print('init');
PdaSource.init();
super.initState();
}
@OverRide
void dispose() {
print('dispose');
PdaSource.dispose();
super.dispose();
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: Center(
child: Text('$_code'),
)
),
);
}
@OverRide
void onEvent(Object code) {
// TODO: implement onEvent
setState(() {
_code=code;
});
}
@OverRide
void onError(Object error) {
// TODO: implement onError
print(error);
setState(() {
_error=error;
});
}
}

Logs

第一次在释放生命周期的时候会提示 PdaScannerPlugin:onCancel;
I/PdaScannerPlugin( 4629): PdaScannerPlugin:onCancel

@ly020044
Copy link

dispose方法在最后面加一句 _subscription = null; 就ok了

@wu9007
Copy link
Owner

wu9007 commented Aug 12, 2020

升级版本到 pda_scanner: ^0.2.8 试试

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