title: How to Develop a flutter chat Application Offline?
body: <p>I'm trying to develop a flutter application with feature chat offline without internet</p>
  <p><a href="https://pub.dev/packages/flutter_bluetooth_serial" rel="nofollow noreferrer">Bluetooth serial</a>  and <a href="https://pub.dev/packages/flutter_blue" rel="nofollow noreferrer">blue</a>  packages have been tried as below:</p>
  <ol>
  <li>list paired devices successfully.</li>
  <li>create socket with remote device successfully.</li>
  <li>connect to that device(mobile) failed,couldn't establish connection with tis socket, only works with serial board devices like Arduino.</li>
  </ol>
  <p>**always getting this : **
  &quot;read failed, socket might closed or timeout, read ret: -1&quot;</p>
  <p>Would you please recommend alternate ways and which is the best and applicable ?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Future&lt;void&gt; connect(String address) async{
      try {
        BluetoothConnection connection = await BluetoothConnection.toAddress(address);
        print('Connected to the device');
  
        connection.input!.listen((Uint8List data) {
          print('Data incoming: ${ascii.decode(data)}');
          connection.output.add(data); // Sending data
  
          if (ascii.decode(data).contains('!')) {
            connection.finish(); // Closing connection
            print('Disconnecting by local host');
          }
        }).onDone(() {
          print('Disconnected by remote request');
        });
      }
      catch (exception) {
        print('Cannot connect, exception occured');
        print(exception.toString());
      }
   }</code></pre>
  </div>
  </div>
  </p>