listener remove future

master
张萌 3 years ago
parent d5783fa4ab
commit 4ba42981ac

@ -3,10 +3,7 @@
<component name="ChangeListManager">
<list default="true" id="2f8e3712-04e2-429a-bcea-c8db1a54008e" name="默认变更列表" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/lib/main.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/main.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/pubspec.lock" beforeDir="false" afterPath="$PROJECT_DIR$/example/pubspec.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/dj_printer.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/dj_printer.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pubspec.lock" beforeDir="false" afterPath="$PROJECT_DIR$/pubspec.lock" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -51,6 +48,7 @@
</component>
<component name="PropertiesComponent">
<property name="dart.analysis.tool.window.force.activate" value="true" />
<property name="dart.analysis.tool.window.visible" value="false" />
<property name="io.flutter.reload.alreadyRun" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="settings.editor.selected.configurable" value="flutter.settings" />

@ -14,10 +14,10 @@ class DjPrinter {
EventChannel("com.discovery.devices");
StreamSubscription? _discoveryStream;
Future<StreamSubscription> addDiscoveryListen(
StreamSubscription addDiscoveryListen(
{required void Function(dynamic data) onReceive,
void Function()? onStart,
void Function()? onFinish}) async {
void Function()? onFinish}) {
if (_discoveryStream == null) {
return _deviceChannel.receiveBroadcastStream().listen((data) {
if (data == "start" && onStart != null) {
@ -43,9 +43,9 @@ class DjPrinter {
static const EventChannel _connectChannel = EventChannel("com.connect");
StreamSubscription? _connectStream;
Future<StreamSubscription> addConnectListen(
StreamSubscription addConnectListen(
{required void Function() onConnect,
required void Function() onDisconnect}) async {
required void Function() onDisconnect}) {
if (_connectStream == null) {
return _connectChannel.receiveBroadcastStream().listen((data) {
if (data == 'connected') {

Loading…
Cancel
Save