Skip to content

Commit

Permalink
Merge pull request #7 from Malte2036/upgrade_example
Browse files Browse the repository at this point in the history
✨ Upgrade example to v1.0.0
  • Loading branch information
Malte2036 authored Nov 3, 2023
2 parents 9549b11 + e66f1ed commit 1aa10af
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 44 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ After completing the `flutter_blue_plus` setup, you can add the following depend

```yaml
dependencies:
flutter_ftms: 0.9.0
flutter_ftms: 1.0.0
```
Then, run `flutter pub get` to install the package.
Expand Down
4 changes: 2 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class _ScanPageState extends State<ScanPage> {
initialData: const [],
builder: (c, snapshot) => scanResultsToWidget(
(snapshot.data ?? [])
.where((element) => element.device.name.isNotEmpty)
.where((element) => element.device.platformName.isNotEmpty)
.toList(),
context),
),
Expand Down Expand Up @@ -133,7 +133,7 @@ class _FTMSPageState extends State<FTMSPage> {
child: Scaffold(
appBar: AppBar(
title: Text(
'${widget.ftmsDevice.name} (${FTMS.getDeviceDataTypeWithoutConnecting(widget.ftmsDevice)})'),
'${widget.ftmsDevice.platformName} (${FTMS.getDeviceDataTypeWithoutConnecting(widget.ftmsDevice)})'),
bottom: const TabBar(
tabs: <Widget>[
Tab(
Expand Down
21 changes: 11 additions & 10 deletions example/lib/widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ Widget scanResultsToWidget(List<ScanResult> data, BuildContext context) {
initialData: false,
builder: (c, snapshot) {
return Text(
d.device.name.isEmpty ? "(unknown device)" : d.device.name,
d.device.platformName.isEmpty
? "(unknown device)"
: d.device.platformName,
);
}),
subtitle: Text(d.device.id.id),
subtitle: Text(d.device.remoteId.str),
leading: SizedBox(
width: 40,
child: Center(
Expand All @@ -49,35 +51,34 @@ Widget scanResultsToWidget(List<ScanResult> data, BuildContext context) {

Widget getButtonForBluetoothDevice(
BluetoothDevice device, BuildContext context) {
return StreamBuilder<BluetoothDeviceState>(
stream: device.state,
return StreamBuilder<BluetoothConnectionState>(
stream: device.connectionState,
builder: (c, snapshot) {
if (!snapshot.hasData) {
return const Text("...");
}
var deviceState = snapshot.data!;
switch (deviceState) {
case BluetoothDeviceState.disconnected:
case BluetoothConnectionState.disconnected:
return ElevatedButton(
child: const Text("Connect"),
onPressed: () async {
final snackBar = SnackBar(
content: Text('Connecting to ${device.name}...'),
content: Text('Connecting to ${device.platformName}...'),
duration: const Duration(seconds: 2),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);

await FTMS.connectToFTMSDevice(device);
device.state.listen((state) async {
if (state == BluetoothDeviceState.disconnected ||
state == BluetoothDeviceState.disconnecting) {
device.connectionState.listen((state) async {
if (state == BluetoothConnectionState.disconnected) {
ftmsBloc.ftmsDeviceDataControllerSink.add(null);
return;
}
});
},
);
case BluetoothDeviceState.connected:
case BluetoothConnectionState.connected:
return SizedBox(
width: 250,
child: Wrap(
Expand Down
44 changes: 14 additions & 30 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.1"
fixnum:
dependency: transitive
description:
name: fixnum
sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -74,18 +66,18 @@ packages:
dependency: transitive
description:
name: flutter_blue_plus
sha256: a977e90b7f9dcece90a95a287f8843e3b9028a61199c41bc279832c096d31d43
sha256: "2df6091f9f3f3dd13dba39e681e9591eb2c243c8aecebcbb737e5bc54ca77521"
url: "https://pub.dev"
source: hosted
version: "1.5.2"
version: "1.20.8"
flutter_ftms:
dependency: "direct main"
description:
name: flutter_ftms
sha256: "9272a099ac61eea0921acc6172ff2f3a238520e87c1e92ba73df0d9ee9c0c29b"
sha256: "2e8c57cfee42a21e88e991d01c37f8ab3f1dee78d87e691920eefd0e37562e35"
url: "https://pub.dev"
source: hosted
version: "0.8.1"
version: "1.0.0"
flutter_lints:
dependency: "direct dev"
description:
Expand Down Expand Up @@ -151,42 +143,42 @@ packages:
dependency: transitive
description:
name: permission_handler
sha256: "33c6a1253d1f95fd06fa74b65b7ba907ae9811f9d5c1d3150e51417d04b8d6a8"
sha256: "284a66179cabdf942f838543e10413246f06424d960c92ba95c84439154fcac8"
url: "https://pub.dev"
source: hosted
version: "10.2.0"
version: "11.0.1"
permission_handler_android:
dependency: transitive
description:
name: permission_handler_android
sha256: d8cc6a62ded6d0f49c6eac337e080b066ee3bce4d405bd9439a61e1f1927bfe8
sha256: f9fddd3b46109bd69ff3f9efa5006d2d309b7aec0f3c1c5637a60a2d5659e76e
url: "https://pub.dev"
source: hosted
version: "10.2.1"
version: "11.1.0"
permission_handler_apple:
dependency: transitive
description:
name: permission_handler_apple
sha256: ee96ac32f5a8e6f80756e25b25b9f8e535816c8e6665a96b6d70681f8c4f7e85
sha256: "99e220bce3f8877c78e4ace901082fb29fa1b4ebde529ad0932d8d664b34f3f5"
url: "https://pub.dev"
source: hosted
version: "9.0.8"
version: "9.1.4"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
sha256: "68abbc472002b5e6dfce47fe9898c6b7d8328d58b5d2524f75e277c07a97eb84"
sha256: "6760eb5ef34589224771010805bea6054ad28453906936f843a8cc4d3a55c4a4"
url: "https://pub.dev"
source: hosted
version: "3.9.0"
version: "3.12.0"
permission_handler_windows:
dependency: transitive
description:
name: permission_handler_windows
sha256: f67cab14b4328574938ecea2db3475dad7af7ead6afab6338772c5f88963e38b
sha256: cc074aace208760f1eee6aa4fae766b45d947df85bc831cde77009cdb4720098
url: "https://pub.dev"
source: hosted
version: "0.1.2"
version: "0.1.3"
plugin_platform_interface:
dependency: transitive
description:
Expand All @@ -195,14 +187,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
protobuf:
dependency: transitive
description:
name: protobuf
sha256: "01dd9bd0fa02548bf2ceee13545d4a0ec6046459d847b6b061d8a27237108a08"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ environment:
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter_ftms: "^0.8.1"
flutter_ftms: "^1.0.0"
flutter:
sdk: flutter

Expand Down

0 comments on commit 1aa10af

Please sign in to comment.