init
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
|
||||
import 'ch934x_serial_platform_interface.dart';
|
||||
|
||||
class Ch934xSerial {
|
||||
Future<String?> getPlatformVersion() {
|
||||
return Ch934xSerialPlatform.instance.getPlatformVersion();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'ch934x_serial_platform_interface.dart';
|
||||
|
||||
/// An implementation of [Ch934xSerialPlatform] that uses method channels.
|
||||
class MethodChannelCh934xSerial extends Ch934xSerialPlatform {
|
||||
/// The method channel used to interact with the native platform.
|
||||
@visibleForTesting
|
||||
final methodChannel = const MethodChannel('ch934x_serial');
|
||||
|
||||
@override
|
||||
Future<String?> getPlatformVersion() async {
|
||||
final version = await methodChannel.invokeMethod<String>(
|
||||
'getPlatformVersion',
|
||||
);
|
||||
return version;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
|
||||
|
||||
import 'ch934x_serial_method_channel.dart';
|
||||
|
||||
abstract class Ch934xSerialPlatform extends PlatformInterface {
|
||||
/// Constructs a Ch934xSerialPlatform.
|
||||
Ch934xSerialPlatform() : super(token: _token);
|
||||
|
||||
static final Object _token = Object();
|
||||
|
||||
static Ch934xSerialPlatform _instance = MethodChannelCh934xSerial();
|
||||
|
||||
/// The default instance of [Ch934xSerialPlatform] to use.
|
||||
///
|
||||
/// Defaults to [MethodChannelCh934xSerial].
|
||||
static Ch934xSerialPlatform get instance => _instance;
|
||||
|
||||
/// Platform-specific implementations should set this with their own
|
||||
/// platform-specific class that extends [Ch934xSerialPlatform] when
|
||||
/// they register themselves.
|
||||
static set instance(Ch934xSerialPlatform instance) {
|
||||
PlatformInterface.verifyToken(instance, _token);
|
||||
_instance = instance;
|
||||
}
|
||||
|
||||
Future<String?> getPlatformVersion() {
|
||||
throw UnimplementedError('platformVersion() has not been implemented.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user