Ver Fonte

修复closeStream无法使用的问题

Kevin há 5 anos atrás
pai
commit
48c7341fd4
4 ficheiros alterados com 32 adições e 31 exclusões
  1. 26 28
      .idea/workspace.xml
  2. 1 1
      example/pubspec.lock
  3. 4 1
      lib/bluetooth_socket.dart
  4. 1 1
      pubspec.yaml

+ 26 - 28
.idea/workspace.xml

@@ -1,10 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ChangeListManager">
-    <list default="true" id="cef19225-ccb5-4e06-af53-e383e247fd01" name="Default Changelist" comment="">
-      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/android/src/main/java/info/geteasy/flutter_bluetooth/FlutterBluetoothPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/info/geteasy/flutter_bluetooth/FlutterBluetoothPlugin.java" afterDir="false" />
-    </list>
+    <list default="true" id="cef19225-ccb5-4e06-af53-e383e247fd01" name="Default Changelist" comment="" />
     <ignored path="$PROJECT_DIR$/.dart_tool/" />
     <ignored path="$PROJECT_DIR$/.idea/" />
     <ignored path="$PROJECT_DIR$/.pub/" />
@@ -41,8 +38,8 @@
       <file pinned="false" current-in-tab="true">
         <entry file="file://$PROJECT_DIR$/android/src/main/java/info/geteasy/flutter_bluetooth/FlutterBluetoothPlugin.java">
           <provider selected="true" editor-type-id="text-editor">
-            <state relative-caret-position="38">
-              <caret line="2" column="24" selection-start-line="2" selection-start-column="24" selection-end-line="2" selection-end-column="24" />
+            <state relative-caret-position="171">
+              <caret line="9" column="41" selection-start-line="9" selection-start-column="41" selection-end-line="9" selection-end-column="41" />
             </state>
           </provider>
         </entry>
@@ -82,56 +79,56 @@
       <foldersAlwaysOnTop value="true" />
     </navigator>
     <panes>
-      <pane id="ProjectPane">
+      <pane id="PackagesPane">
         <subPane>
           <expand>
             <path>
-              <item name="flutter_bluetooth" type="b2602c69:ProjectViewProjectNode" />
-              <item name="flutter_bluetooth" type="462c0819:PsiDirectoryNode" />
+              <item name="flutter_bluetooth" type="58d84e3e:PackageViewProjectNode" />
+              <item name="flutter_bluetooth" type="616d4139:PackageViewModuleNode" />
             </path>
             <path>
-              <item name="flutter_bluetooth" type="b2602c69:ProjectViewProjectNode" />
-              <item name="flutter_bluetooth" type="462c0819:PsiDirectoryNode" />
-              <item name="android" type="462c0819:PsiDirectoryNode" />
+              <item name="flutter_bluetooth" type="58d84e3e:PackageViewProjectNode" />
+              <item name="flutter_bluetooth_android" type="616d4139:PackageViewModuleNode" />
             </path>
             <path>
-              <item name="flutter_bluetooth" type="b2602c69:ProjectViewProjectNode" />
-              <item name="flutter_bluetooth" type="462c0819:PsiDirectoryNode" />
-              <item name="android" type="462c0819:PsiDirectoryNode" />
-              <item name="main" type="462c0819:PsiDirectoryNode" />
+              <item name="flutter_bluetooth" type="58d84e3e:PackageViewProjectNode" />
+              <item name="flutter_bluetooth_android" type="616d4139:PackageViewModuleNode" />
+              <item name="info.geteasy.flutter_bluetooth" type="1f31426a:PackageElementNode" />
             </path>
           </expand>
           <select />
         </subPane>
       </pane>
-      <pane id="PackagesPane">
+      <pane id="AndroidView" />
+      <pane id="ProjectPane">
         <subPane>
           <expand>
             <path>
-              <item name="flutter_bluetooth" type="58d84e3e:PackageViewProjectNode" />
-              <item name="flutter_bluetooth" type="616d4139:PackageViewModuleNode" />
+              <item name="flutter_bluetooth" type="b2602c69:ProjectViewProjectNode" />
+              <item name="flutter_bluetooth" type="462c0819:PsiDirectoryNode" />
             </path>
             <path>
-              <item name="flutter_bluetooth" type="58d84e3e:PackageViewProjectNode" />
-              <item name="flutter_bluetooth_android" type="616d4139:PackageViewModuleNode" />
+              <item name="flutter_bluetooth" type="b2602c69:ProjectViewProjectNode" />
+              <item name="flutter_bluetooth" type="462c0819:PsiDirectoryNode" />
+              <item name="android" type="462c0819:PsiDirectoryNode" />
             </path>
             <path>
-              <item name="flutter_bluetooth" type="58d84e3e:PackageViewProjectNode" />
-              <item name="flutter_bluetooth_android" type="616d4139:PackageViewModuleNode" />
-              <item name="info.geteasy.flutter_bluetooth" type="1f31426a:PackageElementNode" />
+              <item name="flutter_bluetooth" type="b2602c69:ProjectViewProjectNode" />
+              <item name="flutter_bluetooth" type="462c0819:PsiDirectoryNode" />
+              <item name="android" type="462c0819:PsiDirectoryNode" />
+              <item name="main" type="462c0819:PsiDirectoryNode" />
             </path>
           </expand>
           <select />
         </subPane>
       </pane>
-      <pane id="AndroidView" />
       <pane id="Scope" />
     </panes>
   </component>
   <component name="PropertiesComponent">
     <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
     <property name="dart.analysis.tool.window.force.activate" value="false" />
-    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
+    <property name="last_opened_file_path" value="G:/Code/ClothingERP.FullVersion/ClothingERP.FullVersion.Mobile" />
     <property name="show.migrate.to.gradle.popup" value="false" />
   </component>
   <component name="RunDashboard">
@@ -161,6 +158,7 @@
   </component>
   <component name="ToolWindowManager">
     <frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
+    <editor active="true" />
     <layout>
       <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.25586355" />
       <window_info id="Captures" order="1" side_tool="true" />
@@ -205,8 +203,8 @@
     </entry>
     <entry file="file://$PROJECT_DIR$/android/src/main/java/info/geteasy/flutter_bluetooth/FlutterBluetoothPlugin.java">
       <provider selected="true" editor-type-id="text-editor">
-        <state relative-caret-position="38">
-          <caret line="2" column="24" selection-start-line="2" selection-start-column="24" selection-end-line="2" selection-end-column="24" />
+        <state relative-caret-position="171">
+          <caret line="9" column="41" selection-start-line="9" selection-start-column="41" selection-end-line="9" selection-end-column="41" />
         </state>
       </provider>
     </entry>

+ 1 - 1
example/pubspec.lock

@@ -75,7 +75,7 @@ packages:
       path: ".."
       relative: true
     source: path
-    version: "1.0.4"
+    version: "1.0.6"
   flutter_test:
     dependency: "direct dev"
     description: flutter

+ 4 - 1
lib/bluetooth_socket.dart

@@ -15,6 +15,8 @@ class BluetoothSocket {
       StreamController<Uint8List>();
   Stream<Uint8List> get readStream => _readController.stream;
 
+  final StreamController _statusController = StreamController();
+
   final StreamController _closeController = StreamController();
   Stream get closeStream => _closeController.stream;
 
@@ -38,7 +40,7 @@ class BluetoothSocket {
   _handlerEvent() {
     EventChannel('flutter_bluetooth/connectedEvent$address-$uuid')
         .receiveBroadcastStream()
-        .takeUntil(closeStream)
+        .takeUntil(_statusController.stream)
         .listen((event) {
       switch (event['type']) {
         case _MESSAGE_READ:
@@ -47,6 +49,7 @@ class BluetoothSocket {
         case _MESSAGE_CLOSE:
           _status = BluetoothSocketStatusEnum.Disconnect;
           _closeController.add(null);
+          _statusController.add(null);
           break;
         default:
       }

+ 1 - 1
pubspec.yaml

@@ -1,6 +1,6 @@
 name: flutter_bluetooth
 description: 传统蓝牙
-version: 1.0.4
+version: 1.0.6
 author:
 homepage: