添加打印机筛选,删除权限插件

master
章文轩 2 years ago
parent 0094f481f3
commit da66b76e8d

@ -2,7 +2,6 @@
<library name="Flutter Plugins" type="FlutterPluginsLibraryType">
<CLASSES>
<root url="file://$PROJECT_DIR$" />
<root url="file://$PROJECT_DIR$/../.pub-cache/hosted/pub.dartlang.org/permission_handler-7.0.0" />
</CLASSES>
<JAVADOC />
<SOURCES />

@ -104,7 +104,8 @@ public class Bluetooth {
String name = remoteDevice.getName();
System.out.println(name);
System.out.println(remoteDevice.getAddress());
if (remoteDevice != null && name != null) {
System.out.println(remoteDevice.getBluetoothClass().getMajorDeviceClass());
if (remoteDevice != null && name != null&&remoteDevice.getBluetoothClass().getMajorDeviceClass()==1536) {
if (remoteDevice.getBondState() != BluetoothDevice.BOND_BONDED) {
key = "{" + "\"name\":" + "\"" + name + "\"" + ","
+ "\"address\":" + "\"" + remoteDevice.getAddress() + "\"" + ","

@ -6,7 +6,7 @@ import 'package:hy_printer/device.dart';
import 'package:hy_printer/dj_printer.dart';
import 'package:hy_printer/hy_printer.dart';
import 'package:hy_printer_example/scan_page.dart';
import 'package:permission_handler/permission_handler.dart';
// import 'package:permission_handler/permission_handler.dart';
void main() {
runApp(const MyApp());
@ -32,22 +32,22 @@ class _MyAppState extends State<MyApp> {
// setState(() {});
// }
Future<void> initPlatformState() async {
var per = await Permission.bluetooth.isGranted;
if (!per) {
Permission.bluetooth.request();
}
var pers = await Permission.locationWhenInUse.isGranted;
if (!pers) {
Permission.locationWhenInUse.request();
}
var per1 = await Permission.bluetoothScan.isGranted;
if (!per1) {
Permission.bluetoothScan.request();
}
var per2 = await Permission.bluetoothConnect.isGranted;
if (!per2) {
Permission.bluetoothConnect.request();
}
// var per = await Permission.bluetooth.isGranted;
// if (!per) {
// Permission.bluetooth.request();
// }
// var pers = await Permission.locationWhenInUse.isGranted;
// if (!pers) {
// Permission.locationWhenInUse.request();
// }
// var per1 = await Permission.bluetoothScan.isGranted;
// if (!per1) {
// Permission.bluetoothScan.request();
// }
// var per2 = await Permission.bluetoothConnect.isGranted;
// if (!per2) {
// Permission.bluetoothConnect.request();
// }
DjPrinter().init();
DjPrinter().addDiscoveryListen(onReceive: (data) {
@ -99,13 +99,14 @@ class _MyAppState extends State<MyApp> {
),
...devices
.map((e) => TextButton(
onPressed: () {
[Permission.bluetoothConnect,].request().then((value) async {
print("===============${value[Permission.bluetoothConnect]}");
if(value[Permission.bluetoothConnect]!=PermissionStatus.denied){
await DjPrinter().connect(e.address);
}
});
onPressed: ()async {
// [Permission.bluetoothConnect,].request().then((value) async {
// print("===============${value[Permission.bluetoothConnect]}");
// if(value[Permission.bluetoothConnect]!=PermissionStatus.denied){
//
// }
// });
await DjPrinter().connect(e.address);
//
},

@ -116,27 +116,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
permission_handler:
dependency: "direct main"
description:
name: permission_handler
url: "https://pub.dartlang.org"
source: hosted
version: "7.0.0"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "3.7.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
sky_engine:
dependency: transitive
description: flutter
@ -193,4 +172,4 @@ packages:
version: "2.1.2"
sdks:
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.5.0"
flutter: ">=1.20.0"

@ -17,7 +17,7 @@ environment:
dependencies:
flutter:
sdk: flutter
permission_handler: 7.0.0
# permission_handler: 10.0.0
hy_printer:
# When depending on this package from a real application you should use:
# hy_printer: ^x.y.z

@ -102,27 +102,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
permission_handler:
dependency: "direct main"
description:
name: permission_handler
url: "https://pub.dartlang.org"
source: hosted
version: "7.0.0"
permission_handler_platform_interface:
dependency: transitive
description:
name: permission_handler_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "3.7.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
sky_engine:
dependency: transitive
description: flutter
@ -179,4 +158,4 @@ packages:
version: "2.1.2"
sdks:
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.5.0"
flutter: ">=1.20.0"

@ -11,7 +11,7 @@ dependencies:
flutter:
sdk: flutter
# flutter_blue_plus: ^1.3.1
permission_handler: 7.0.0
# permission_handler: 10.0.0
dev_dependencies:
flutter_test:
sdk: flutter

Loading…
Cancel
Save