Navaron Bracke

add platform interface stub

... ... @@ -12,6 +12,7 @@ export 'src/enums/torch_state.dart';
export 'src/mobile_scanner.dart';
export 'src/mobile_scanner_controller.dart';
export 'src/mobile_scanner_exception.dart';
export 'src/mobile_scanner_platform_interface.dart';
export 'src/objects/address.dart';
export 'src/objects/barcode.dart';
export 'src/objects/barcode_capture.dart';
... ...
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:mobile_scanner/src/mobile_scanner_platform_interface.dart';
/// An implementation of [MobileScannerPlatform] that uses method channels.
class MethodChannelMobileScanner extends MobileScannerPlatform {
/// The method channel used to interact with the native platform.
@visibleForTesting
final methodChannel = const MethodChannel('dev.steenbakker.mobile_scanner/scanner/method');
/// The event channel that sends back scanned barcode events.
@visibleForTesting
final eventChannel = const EventChannel('dev.steenbakker.mobile_scanner/scanner/event');
}
... ...
import 'package:mobile_scanner/src/method_channel/mobile_scanner_method_channel.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
/// The platform interface for the `mobile_scanner` plugin.
abstract class MobileScannerPlatform extends PlatformInterface {
/// Constructs a MobileScannerPlatform.
MobileScannerPlatform() : super(token: _token);
static final Object _token = Object();
static MobileScannerPlatform _instance = MethodChannelMobileScanner();
/// The default instance of [MobileScannerPlatform] to use.
///
/// Defaults to [MethodChannelMobileScanner].
static MobileScannerPlatform get instance => _instance;
/// Platform-specific implementations should set this with their own
/// platform-specific class that extends [MobileScannerPlatform] when
/// they register themselves.
static set instance(MobileScannerPlatform instance) {
PlatformInterface.verifyToken(instance, _token);
_instance = instance;
}
}
... ...
... ... @@ -25,6 +25,7 @@ dependencies:
flutter_web_plugins:
sdk: flutter
js: ">=0.6.3 <0.8.0"
plugin_platform_interface: ^2.0.2
dev_dependencies:
flutter_test:
... ...