Commit 96ba0941 authored by Andrey's avatar Andrey

Refactoring

parent aa490654
...@@ -38,10 +38,6 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -38,10 +38,6 @@ class _MyHomePageState extends State<MyHomePage> {
List<BluetoothDevice> _devices = []; List<BluetoothDevice> _devices = [];
StreamSubscription _scanResultsSubscription; StreamSubscription _scanResultsSubscription;
StreamSubscription _isScanningSubscription; StreamSubscription _isScanningSubscription;
// Buffers used for rescan before sending the data
List<BluetoothDevice> _bufDevices = [];
StreamSubscription _bufScanSubscription;
// StreamSubscription _isScanningSubscription;
void _startScanDevices() { void _startScanDevices() {
setState(() { setState(() {
...@@ -59,7 +55,7 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -59,7 +55,7 @@ class _MyHomePageState extends State<MyHomePage> {
_isScanningSubscription = _isScanningSubscription =
bluetoothManager.isScanning.listen((isScanningCurrent) async { bluetoothManager.isScanning.listen((isScanningCurrent) async {
// if isScanning value changed (scan just stopped) // If isScanning value changed (scan just stopped)
if (_isScanning && !isScanningCurrent) { if (_isScanning && !isScanningCurrent) {
_scanResultsSubscription.cancel(); _scanResultsSubscription.cancel();
_isScanningSubscription.cancel(); _isScanningSubscription.cancel();
...@@ -81,12 +77,10 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -81,12 +77,10 @@ class _MyHomePageState extends State<MyHomePage> {
void _testPrint(BluetoothDevice printer) async { void _testPrint(BluetoothDevice printer) async {
const int timeout = 5; const int timeout = 5;
if (_isScanning) { if (_isScanning) {
// print('Print failed (scanning in progress)');
showToast('Print failed (scanning in progress)'); showToast('Print failed (scanning in progress)');
return; return;
} }
if (_isPrinting) { if (_isPrinting) {
// print('Print failed (another printing in progress)');
showToast('Print failed (another printing in progress)'); showToast('Print failed (another printing in progress)');
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment