WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ public void onMethodCall(MethodCall call, Result result) {
break;
}

case "name":
{
String name = mBluetoothAdapter.getName();
if (name == null)
name = "";
result.success(name);
break;
}

case "isOn":
{
result.success(mBluetoothAdapter.isEnabled());
Expand Down
2 changes: 2 additions & 0 deletions ios/Classes/FlutterBluePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
} else {
result(@(NO));
}
} else if([@"name" isEqualToString:call.method]) {
result([[UIDevice currentDevice] name]);
} else if([@"startScan" isEqualToString:call.method]) {
// Clear any existing scan results
[self.scannedPeripherals removeAllObjects];
Expand Down
4 changes: 4 additions & 0 deletions lib/src/flutter_blue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class FlutterBlue {
Future<bool> get isAvailable =>
_channel.invokeMethod('isAvailable').then<bool>((d) => d);

/// Return the friendly Bluetooth name of the local Bluetooth adapter
Future<String> get name =>
_channel.invokeMethod('name').then<String>((d) => d);

/// Checks if Bluetooth functionality is turned on
Future<bool> get isOn => _channel.invokeMethod('isOn').then<bool>((d) => d);

Expand Down