Yuzo_Imabori
@Yuzo_Imabori

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

flutter_blue_plusを使ってテストサンプルがうまく動作しません

flutter_blue_plusプラグインを使ってテストサンプルを以下に試しに実行しましたがうまく起動しません。

現象は途中で例外エラーで停止しているようです。昨年12月に勉強しだしたflutter素人です。ペリフェラル側BLEデバイスとスマホとでテストアプリを作成したいので、教えて頂けないでしょうか。よろしくお願いいたします。

Xcodeエラー内容)
libsystem_kernel.dylib`:
0x1eedc8350 <+0>: mov x16, #0x209
0x1eedc8354 <+4>: svc #0x80
-> 0x1eedc8358 <+8>: b.lo 0x1eedc8378 ; <+40>
0x1eedc835c <+12>: pacibsp
0x1eedc8360 <+16>: stp x29, x30, [sp, #-0x10]!
0x1eedc8364 <+20>: mov x29, sp
0x1eedc8368 <+24>: bl 0x1eedbd76c ; cerror_nocancel
0x1eedc836c <+28>: mov sp, x29
0x1eedc8370 <+32>: ldp x29, x30, [sp], #0x10
0x1eedc8374 <+36>: retab
0x1eedc8378 <+40>: ret

テストアプリのコードは以下です。

import 'package:flutter/material.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: BleScanner(),
);
}
}

class BleScanner extends StatefulWidget {
@override
_BleScannerState createState() => _BleScannerState();
}

class _BleScannerState extends State {
FlutterBluePlus flutterBlue = FlutterBluePlus();
List devices = [];

@override
void initState() {
super.initState();
startScanning();
}

void startScanning() async {
await FlutterBluePlus.startScan();
FlutterBluePlus.scanResults.listen((results) {
for (ScanResult result in results) {
if (!devices.contains(result.device)) {
setState(() {
devices.add(result.device);
});
}
}
});
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('BLE Scanner'),
),
body: ListView.builder(
itemCount: devices.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(devices[index].name),
subtitle: Text(devices[index].id.toString()),
);
},
),
);
}

@override
void dispose() {
FlutterBluePlus.stopScan();
super.dispose();
}
}

0

No Answers yet.

Your answer might help someone💌