我正试图抓住<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<button class="btn btn-warning">
<i class="fa fa-trash-o fa-lg"></i>
</button>
<button class="btn btn-primary">
<i class="fa fa-trash-o fa-lg"></i> Delete
</button>
<button class="btn btn-danger">
Delete <i class="fa fa-trash-o fa-lg"></i>
</button>
提出的PlatformException
。我在尝试等待时尝试了一次除块以外的其他操作,但是在调试器中仍然会引发异常。我在做什么错了?
FlutterBlue.instance
更新:实际上,我什至不确定这与异步/等待有关,我相信import 'package:flutter/services.dart';
import 'package:flutter_blue/flutter_blue.dart';
...
Stream<BluetoothState> _getBluetoothState() async* {
bool isAvailable = false;
try {
// This always raises a PlatformException
// in the vscode debugger
isAvailable = await FlutterBlue.instance.isAvailable;
} on PlatformException catch(e) {
// This doesn't seem to ever catch anything
debugPrint('$e');
} catch(e) {
// Doesn't catch my exception either.
debugPrint('$e');
}
// Wrap the original stream that fails to handle this exception..
if (isAvailable) {
await for (BluetoothState state in FlutterBlue.instance.state) {
yield state;
}
} else {
yield BluetoothState.unavailable;
}
}
会引发错误,并且不是异步的。这只是吸气剂。我是飞镖新手,这让我很失落。