Add Android scan mode setting (#212)
* Add Android scan mode setting * Format pigeon generated code * format whole project * Fix windows compilation because of generated code order * Fix unwanted imports * Add doc comment for AndroidOptions * Update code doc
This commit is contained in:
@@ -52,7 +52,8 @@ class MockUniversalBle extends UniversalBlePlatform {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> connect(String deviceId, {bool autoConnect = false, Duration? connectionTimeout}) async {
|
||||
Future<void> connect(String deviceId,
|
||||
{bool autoConnect = false, Duration? connectionTimeout}) async {
|
||||
updateConnection(deviceId, true);
|
||||
_connectionStateMap[deviceId] = BleConnectionState.connected;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,11 @@ class _ScannerScreenState extends State<ScannerScreen> {
|
||||
_isScanning = true;
|
||||
});
|
||||
try {
|
||||
PlatformConfig? platformConfig;
|
||||
PlatformConfig platformConfig = PlatformConfig(
|
||||
android: AndroidOptions(
|
||||
scanMode: AndroidScanMode.lowLatency,
|
||||
),
|
||||
);
|
||||
if (kIsWeb && _webServicesController.text.isNotEmpty) {
|
||||
List<String> webServices = _webServicesController.text
|
||||
.split(',')
|
||||
@@ -96,10 +100,9 @@ class _ScannerScreenState extends State<ScannerScreen> {
|
||||
return s.trim();
|
||||
}
|
||||
}).toList();
|
||||
platformConfig = PlatformConfig(
|
||||
web: WebOptions(optionalServices: webServices),
|
||||
);
|
||||
platformConfig.web = WebOptions(optionalServices: webServices);
|
||||
}
|
||||
|
||||
await UniversalBle.startScan(
|
||||
scanFilter: scanFilter,
|
||||
platformConfig: platformConfig,
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'package:url_launcher/url_launcher.dart';
|
||||
class AppDrawer extends StatefulWidget {
|
||||
final QueueType? queueType;
|
||||
final Function(QueueType)? onQueueTypeChanged;
|
||||
|
||||
|
||||
const AppDrawer({
|
||||
super.key,
|
||||
this.queueType,
|
||||
@@ -87,7 +87,8 @@ class _AppDrawerState extends State<AppDrawer> {
|
||||
),
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
padding:
|
||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Column(
|
||||
children: [
|
||||
_buildQueueOption(
|
||||
|
||||
@@ -66,7 +66,8 @@ class _ScanFilterWidgetState extends State<ScanFilterWidget> {
|
||||
.where((s) => s.isNotEmpty)
|
||||
.toList();
|
||||
for (String manufacturer in manufacturerData) {
|
||||
final companyIdentifier = companyService.parseCompanyIdentifier(manufacturer);
|
||||
final companyIdentifier =
|
||||
companyService.parseCompanyIdentifier(manufacturer);
|
||||
|
||||
if (companyIdentifier == null) {
|
||||
throw Exception(
|
||||
|
||||
@@ -2,23 +2,23 @@ import 'package:flutter/material.dart';
|
||||
import 'package:universal_ble_example/data/company_identifier_service.dart';
|
||||
|
||||
/// A reusable widget that displays company information for a given company ID.
|
||||
///
|
||||
///
|
||||
/// This widget fetches the company name from the CompanyIdentifierService
|
||||
/// and displays it in a consistent format. If no company name is found,
|
||||
/// the widget returns an empty SizedBox.
|
||||
class CompanyInfoWidget extends StatelessWidget {
|
||||
/// The company ID to look up
|
||||
final int companyId;
|
||||
|
||||
|
||||
/// Optional text style for the "Company:" label
|
||||
final TextStyle? labelStyle;
|
||||
|
||||
|
||||
/// Optional text style for the company name
|
||||
final TextStyle? nameStyle;
|
||||
|
||||
|
||||
/// Optional padding around the widget
|
||||
final EdgeInsets? padding;
|
||||
|
||||
|
||||
/// Optional color scheme. If not provided, will be obtained from Theme
|
||||
final ColorScheme? colorScheme;
|
||||
|
||||
@@ -33,8 +33,9 @@ class CompanyInfoWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final companyName = CompanyIdentifierService.instance.getCompanyName(companyId);
|
||||
|
||||
final companyName =
|
||||
CompanyIdentifierService.instance.getCompanyName(companyId);
|
||||
|
||||
if (companyName == null) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user