2023-10-20 13:49:23 +08:00
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
|
|
|
import 'jc_printer_platform_interface.dart';
|
|
|
|
|
|
|
|
/// An implementation of [JcPrinterPlatform] that uses method channels.
|
|
|
|
class MethodChannelJcPrinter extends JcPrinterPlatform {
|
|
|
|
/// The method channel used to interact with the native platform.
|
|
|
|
@visibleForTesting
|
|
|
|
final methodChannel = const MethodChannel('jc_printer');
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<String?> getPlatformVersion() async {
|
|
|
|
final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
|
|
|
|
return version;
|
|
|
|
}
|
2023-10-20 17:45:24 +08:00
|
|
|
|
|
|
|
@override
|
2023-10-22 12:31:46 +08:00
|
|
|
Future<bool> connect(String name) async {
|
|
|
|
final result = await methodChannel.invokeMethod<bool>('connect', name);
|
2023-10-20 17:45:24 +08:00
|
|
|
print(result);
|
2023-10-22 12:31:46 +08:00
|
|
|
return result ?? false;
|
2023-10-20 17:45:24 +08:00
|
|
|
}
|
2023-10-20 13:49:23 +08:00
|
|
|
}
|