From 17a0462001af81b7ea8e88477ac2b8db827e5da6 Mon Sep 17 00:00:00 2001 From: angcyo Date: Tue, 9 Dec 2025 17:48:42 +0800 Subject: [PATCH 1/3] Update FBP version ^1.36.8 --- .../extension/bluetooth_characteristic_extension.dart | 4 +++- lib/src/extension/bluetooth_descriptor_extension.dart | 4 +++- lib/src/extension/bluetooth_service_extension.dart | 1 + .../extension/characteristic_properties_extension.dart | 1 + lib/src/windows/bluetooth_characteristic_windows.dart | 6 ++++-- lib/src/windows/bluetooth_device_windows.dart | 1 + lib/src/windows/flutter_blue_plus_windows.dart | 9 +++++++++ lib/src/windows/windows.dart | 1 + lib/src/wrapper/flutter_blue_plus_wrapper.dart | 5 +++++ pubspec.yaml | 7 ++++++- 10 files changed, 34 insertions(+), 5 deletions(-) diff --git a/lib/src/extension/bluetooth_characteristic_extension.dart b/lib/src/extension/bluetooth_characteristic_extension.dart index b34a4eb..91a7343 100644 --- a/lib/src/extension/bluetooth_characteristic_extension.dart +++ b/lib/src/extension/bluetooth_characteristic_extension.dart @@ -1,3 +1,4 @@ +import 'package:flutter_blue_plus_platform_interface/flutter_blue_plus_platform_interface.dart'; import 'package:flutter_blue_plus_windows/flutter_blue_plus_windows.dart'; extension BluetoothCharacteristicExtension on BluetoothCharacteristic { @@ -8,7 +9,8 @@ extension BluetoothCharacteristicExtension on BluetoothCharacteristic { characteristicUuid: characteristicUuid, descriptors: [for (final d in descriptors) d.toProto()], properties: properties.toProto(), - primaryServiceUuid: null, // TODO: API changes + primaryServiceUuid: null, + instanceId: 0, // TODO: API changes ); } } diff --git a/lib/src/extension/bluetooth_descriptor_extension.dart b/lib/src/extension/bluetooth_descriptor_extension.dart index b3c5e86..543e970 100644 --- a/lib/src/extension/bluetooth_descriptor_extension.dart +++ b/lib/src/extension/bluetooth_descriptor_extension.dart @@ -1,4 +1,5 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart'; +import 'package:flutter_blue_plus_platform_interface/flutter_blue_plus_platform_interface.dart'; extension BluetoothDescriptorExtension on BluetoothDescriptor { BmBluetoothDescriptor toProto() { @@ -7,7 +8,8 @@ extension BluetoothDescriptorExtension on BluetoothDescriptor { serviceUuid: serviceUuid, characteristicUuid: characteristicUuid, descriptorUuid: descriptorUuid, - primaryServiceUuid: null, // TODO: API changes + primaryServiceUuid: null, + instanceId: 0, // TODO: API changes ); } } diff --git a/lib/src/extension/bluetooth_service_extension.dart b/lib/src/extension/bluetooth_service_extension.dart index c094e2e..c2b0af5 100644 --- a/lib/src/extension/bluetooth_service_extension.dart +++ b/lib/src/extension/bluetooth_service_extension.dart @@ -1,3 +1,4 @@ +import 'package:flutter_blue_plus_platform_interface/flutter_blue_plus_platform_interface.dart'; import 'package:flutter_blue_plus_windows/flutter_blue_plus_windows.dart'; extension BluetoothServiceExtension on BluetoothService { diff --git a/lib/src/extension/characteristic_properties_extension.dart b/lib/src/extension/characteristic_properties_extension.dart index f254ba4..b61baaa 100644 --- a/lib/src/extension/characteristic_properties_extension.dart +++ b/lib/src/extension/characteristic_properties_extension.dart @@ -1,4 +1,5 @@ import 'package:flutter_blue_plus/flutter_blue_plus.dart'; +import 'package:flutter_blue_plus_platform_interface/flutter_blue_plus_platform_interface.dart'; extension CharacteristicPropertiesExtension on CharacteristicProperties { BmCharacteristicProperties toProto() { diff --git a/lib/src/windows/bluetooth_characteristic_windows.dart b/lib/src/windows/bluetooth_characteristic_windows.dart index e5d47ef..ca125ff 100644 --- a/lib/src/windows/bluetooth_characteristic_windows.dart +++ b/lib/src/windows/bluetooth_characteristic_windows.dart @@ -28,7 +28,8 @@ class BluetoothCharacteristicWindows extends BluetoothCharacteristic { serviceUuid: descriptor.serviceUuid, characteristicUuid: descriptor.characteristicUuid, descriptorUuid: descriptor.uuid, - primaryServiceUuid: null, // TODO: API changes + primaryServiceUuid: null, + instanceId: 0, // TODO: API changes ), ], properties: BmCharacteristicProperties( @@ -46,7 +47,8 @@ class BluetoothCharacteristicWindows extends BluetoothCharacteristic { // TODO: implementation missing indicateEncryptionRequired: false, ), - primaryServiceUuid: null, // TODO: API changes + primaryServiceUuid: null, + instanceId: 0, // TODO: API changes ), ); diff --git a/lib/src/windows/bluetooth_device_windows.dart b/lib/src/windows/bluetooth_device_windows.dart index d57fea0..a9a1fab 100644 --- a/lib/src/windows/bluetooth_device_windows.dart +++ b/lib/src/windows/bluetooth_device_windows.dart @@ -253,6 +253,7 @@ class BluetoothDeviceWindows extends FBP.BluetoothDevice { Future createBond({ int timeout = 90, // TODO: implementation missing + Uint8List? pin, }) async { try { await WinBle.pair(_address); diff --git a/lib/src/windows/flutter_blue_plus_windows.dart b/lib/src/windows/flutter_blue_plus_windows.dart index 901f965..d5d14c8 100644 --- a/lib/src/windows/flutter_blue_plus_windows.dart +++ b/lib/src/windows/flutter_blue_plus_windows.dart @@ -123,6 +123,15 @@ class FlutterBluePlusWindows { // TODO: compare with original lib static Stream> get scanResults => _scanResultsList.stream; + static Stream> get onScanResults { + if (isScanningNow) { + return _scanResultsList.stream; + } else { + // skip previous results & push empty list + return _scanResultsList.stream.skip(1).newStreamWithInitialValue([]); + } + } + static Stream get adapterState async* { await _initialize(); yield _state; diff --git a/lib/src/windows/windows.dart b/lib/src/windows/windows.dart index dd0b813..749b0e4 100644 --- a/lib/src/windows/windows.dart +++ b/lib/src/windows/windows.dart @@ -3,6 +3,7 @@ import 'dart:developer'; import 'dart:io'; import 'dart:typed_data'; +import 'package:flutter_blue_plus_platform_interface/flutter_blue_plus_platform_interface.dart'; import 'package:flutter_blue_plus_windows/flutter_blue_plus_windows.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart' as FBP; diff --git a/lib/src/wrapper/flutter_blue_plus_wrapper.dart b/lib/src/wrapper/flutter_blue_plus_wrapper.dart index 33da5a7..e56270b 100644 --- a/lib/src/wrapper/flutter_blue_plus_wrapper.dart +++ b/lib/src/wrapper/flutter_blue_plus_wrapper.dart @@ -68,6 +68,11 @@ class FlutterBluePlus { return FBP.FlutterBluePlus.scanResults; } + static Stream> get onScanResults { + if (Platform.isWindows) return FlutterBluePlusWindows.onScanResults; + return FBP.FlutterBluePlus.onScanResults; + } + static bool get isScanningNow { if (Platform.isWindows) return FlutterBluePlusWindows.isScanningNow; return FBP.FlutterBluePlus.isScanningNow; diff --git a/pubspec.yaml b/pubspec.yaml index d1a8c48..947fb5a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,6 +8,11 @@ environment: sdk: ">=3.0.0 <4.0.0" dependencies: - flutter_blue_plus: ">=1.32.4 <1.35.0" + # https://pub.dev/packages/flutter_blue_plus + flutter_blue_plus: ^1.36.8 + # https://pub.dev/packages/flutter_blue_plus_platform_interface + flutter_blue_plus_platform_interface: 7.0.0 + # https://pub.dev/packages/win_ble win_ble: ">=1.1.1" + # https://pub.dev/packages/stream_with_value stream_with_value: ">=0.5.0" From e19e0c06b82742024deb7e90474476342dd25d9a Mon Sep 17 00:00:00 2001 From: angcyo Date: Wed, 11 Mar 2026 15:29:51 +0800 Subject: [PATCH 2/3] + Platform-specific assets --- pubspec.yaml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 947fb5a..f330351 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: flutter_blue_plus_windows description: Flutter blue plus for Windows version: 1.26.1 repository: https://github.com/chan150/flutter_blue_plus_windows -#publish_to: none +publish_to: none environment: sdk: ">=3.0.0 <4.0.0" @@ -12,7 +12,11 @@ dependencies: flutter_blue_plus: ^1.36.8 # https://pub.dev/packages/flutter_blue_plus_platform_interface flutter_blue_plus_platform_interface: 7.0.0 - # https://pub.dev/packages/win_ble - win_ble: ">=1.1.1" # https://pub.dev/packages/stream_with_value stream_with_value: ">=0.5.0" + # https://pub.dev/packages/win_ble + #win_ble: ">=1.1.1" + win_ble: #^1.26.1 + git: + url: git@github.com:FlutterStudioIst/win_ble.git + ref: 1.1.1-fix1 From 89070aa283a08555aa37d2c65aef59f237cdceb1 Mon Sep 17 00:00:00 2001 From: angcyo Date: Wed, 11 Mar 2026 15:30:35 +0800 Subject: [PATCH 3/3] init --- .../Flutter/GeneratedPluginRegistrant.swift | 2 +- example/macos/Podfile.lock | 22 +++++++++++++------ .../macos/Runner.xcodeproj/project.pbxproj | 8 +++---- .../xcshareddata/xcschemes/Runner.xcscheme | 3 ++- example/macos/Runner/AppDelegate.swift | 6 ++++- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/example/macos/Flutter/GeneratedPluginRegistrant.swift b/example/macos/Flutter/GeneratedPluginRegistrant.swift index bb4b4e2..c8c9bea 100644 --- a/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,7 +5,7 @@ import FlutterMacOS import Foundation -import flutter_blue_plus +import flutter_blue_plus_darwin import path_provider_foundation func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { diff --git a/example/macos/Podfile.lock b/example/macos/Podfile.lock index c616687..a0857d8 100644 --- a/example/macos/Podfile.lock +++ b/example/macos/Podfile.lock @@ -1,22 +1,30 @@ PODS: - - flutter_blue_plus (0.0.1): + - flutter_blue_plus_darwin (0.0.2): + - Flutter - FlutterMacOS - FlutterMacOS (1.0.0) + - path_provider_foundation (0.0.1): + - Flutter + - FlutterMacOS DEPENDENCIES: - - flutter_blue_plus (from `Flutter/ephemeral/.symlinks/plugins/flutter_blue_plus/macos`) + - flutter_blue_plus_darwin (from `Flutter/ephemeral/.symlinks/plugins/flutter_blue_plus_darwin/darwin`) - FlutterMacOS (from `Flutter/ephemeral`) + - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) EXTERNAL SOURCES: - flutter_blue_plus: - :path: Flutter/ephemeral/.symlinks/plugins/flutter_blue_plus/macos + flutter_blue_plus_darwin: + :path: Flutter/ephemeral/.symlinks/plugins/flutter_blue_plus_darwin/darwin FlutterMacOS: :path: Flutter/ephemeral + path_provider_foundation: + :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin SPEC CHECKSUMS: - flutter_blue_plus: e2868679021f19d12a8c0c58a33f1df66ec7fa6a - FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 + flutter_blue_plus_darwin: 20a08bfeaa0f7804d524858d3d8744bcc1b6dbc3 + FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1 + path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880 PODFILE CHECKSUM: b5ff078e9cf81bae88fdc8e0ce3668e57b68e9b6 -COCOAPODS: 1.14.3 +COCOAPODS: 1.16.2 diff --git a/example/macos/Runner.xcodeproj/project.pbxproj b/example/macos/Runner.xcodeproj/project.pbxproj index 5235821..be6047d 100644 --- a/example/macos/Runner.xcodeproj/project.pbxproj +++ b/example/macos/Runner.xcodeproj/project.pbxproj @@ -258,7 +258,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1430; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 331C80D4294CF70F00263BE5 = { @@ -552,7 +552,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -632,7 +632,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -679,7 +679,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index b2ce846..564d199 100644 --- a/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ diff --git a/example/macos/Runner/AppDelegate.swift b/example/macos/Runner/AppDelegate.swift index d53ef64..b3c1761 100644 --- a/example/macos/Runner/AppDelegate.swift +++ b/example/macos/Runner/AppDelegate.swift @@ -1,9 +1,13 @@ import Cocoa import FlutterMacOS -@NSApplicationMain +@main class AppDelegate: FlutterAppDelegate { override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { return true } + + override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } }