diff --git a/.packages b/.packages index fce6f89..b460eb6 100644 --- a/.packages +++ b/.packages @@ -1,26 +1,34 @@ -# Generated by pub on 2021-02-08 17:00:18.218789. -async:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/async-2.5.0-nullsafety.1/lib/ -boolean_selector:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/boolean_selector-2.1.0-nullsafety.1/lib/ -characters:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/characters-1.1.0-nullsafety.3/lib/ -charcode:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/charcode-1.2.0-nullsafety.1/lib/ -clock:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/clock-1.1.0-nullsafety.1/lib/ -collection:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/collection-1.15.0-nullsafety.3/lib/ -fake_async:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/fake_async-1.2.0-nullsafety.1/lib/ -flutter:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/packages/flutter/lib/ -flutter_test:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/packages/flutter_test/lib/ -flutter_web_plugins:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/packages/flutter_web_plugins/lib/ -matcher:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/matcher-0.12.10-nullsafety.1/lib/ -meta:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/meta-1.3.0-nullsafety.3/lib/ -path:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/path-1.8.0-nullsafety.1/lib/ -qr:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/qr-1.3.0/lib/ -qr_flutter:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/qr_flutter-3.2.0/lib/ -sky_engine:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/bin/cache/pkg/sky_engine/lib/ -source_span:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/source_span-1.8.0-nullsafety.2/lib/ -stack_trace:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/stack_trace-1.10.0-nullsafety.1/lib/ -stream_channel:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/stream_channel-2.1.0-nullsafety.1/lib/ -string_scanner:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/string_scanner-1.1.0-nullsafety.1/lib/ -term_glyph:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/term_glyph-1.2.0-nullsafety.1/lib/ -test_api:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/test_api-0.2.19-nullsafety.2/lib/ -typed_data:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/typed_data-1.3.0-nullsafety.3/lib/ -vector_math:file:///Users/air/develop_tool/flutter_macos_1.22.0-stable/.pub-cache/hosted/pub.dartlang.org/vector_math-2.1.0-nullsafety.3/lib/ +# This file is deprecated. Tools should instead consume +# `.dart_tools/package_config.json`. +# +# For more info see: https://dart.dev/go/dot-packages-deprecation +# +# Generated by pub on 2021-03-12 16:54:46.545979. +ai_barcode_platform_interface:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/ai_barcode_platform_interface-2.0.0/lib/ +ai_barcode_web:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/ai_barcode_web-1.0.0/lib/ +async:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/async-2.5.0/lib/ +boolean_selector:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/boolean_selector-2.1.0/lib/ +characters:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/characters-1.1.0/lib/ +charcode:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/charcode-1.2.0/lib/ +clock:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/clock-1.1.0/lib/ +collection:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/collection-1.15.0/lib/ +fake_async:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/fake_async-1.2.0/lib/ +flutter:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/packages/flutter/lib/ +flutter_test:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/packages/flutter_test/lib/ +flutter_web_plugins:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/packages/flutter_web_plugins/lib/ +js:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/js-0.6.3/lib/ +matcher:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/matcher-0.12.10/lib/ +meta:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/meta-1.3.0/lib/ +path:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/path-1.8.0/lib/ +qr:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/qr-1.3.0/lib/ +qr_flutter:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/qr_flutter-3.2.0/lib/ +sky_engine:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/bin/cache/pkg/sky_engine/lib/ +source_span:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/source_span-1.8.0/lib/ +stack_trace:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/stack_trace-1.10.0/lib/ +stream_channel:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/stream_channel-2.1.0/lib/ +string_scanner:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/string_scanner-1.1.0/lib/ +term_glyph:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/term_glyph-1.2.0/lib/ +test_api:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/test_api-0.2.19/lib/ +typed_data:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/typed_data-1.3.0/lib/ +vector_math:file:///Users/air/develop_tool/flutter_macos_2.0.0-stable/.pub-cache/hosted/pub.flutter-io.cn/vector_math-2.1.0/lib/ ai_barcode:lib/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e46450..b285e54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [1.6.0] + +* improve: improve design +* fix: something + ## [1.2.0] * adapter flutter = v1.22 diff --git a/example/pubspec.lock b/example/pubspec.lock index 3423f77..9dea3aa 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -5,7 +5,7 @@ packages: dependency: "direct main" description: name: ai_awesome_message - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.0.0" ai_barcode: @@ -14,70 +14,84 @@ packages: path: ".." relative: true source: path - version: "1.2.0" + version: "2.0.0" + ai_barcode_platform_interface: + dependency: transitive + description: + name: ai_barcode_platform_interface + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" + ai_barcode_web: + dependency: transitive + description: + name: ai_barcode_web + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.0" airoute: dependency: "direct main" description: name: airoute - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.0.0" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: name: cupertino_icons - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "0.1.3" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -93,60 +107,67 @@ packages: description: flutter source: sdk version: "0.0.0" + js: + dependency: transitive + description: + name: js + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.6.3" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" permission_handler: dependency: "direct main" description: name: permission_handler - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "5.1.0+2" permission_handler_platform_interface: dependency: transitive description: name: permission_handler_platform_interface - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "2.0.2" plugin_platform_interface: dependency: transitive description: name: plugin_platform_interface - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.2" + version: "1.0.3" qr: dependency: transitive description: name: qr - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.3.0" qr_flutter: dependency: transitive description: name: qr_flutter - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "3.2.0" sky_engine: @@ -158,58 +179,58 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" sdks: - dart: ">=2.10.0-110 <2.11.0" - flutter: ">=1.20.0 <2.0.0" + dart: ">=2.12.0-0.0 <3.0.0" + flutter: ">=1.20.0" diff --git a/lib/ai_barcode.dart b/lib/ai_barcode.dart index fbeb5c0..e24295f 100644 --- a/lib/ai_barcode.dart +++ b/lib/ai_barcode.dart @@ -1,14 +1,5 @@ library ai_barcode; /// -/// Import -import 'package:ai_barcode/src/creator/ai_barcode_platform_creator_interface.dart'; -import 'package:ai_barcode/src/scanner/ai_barcode_platform_scanner_interface.dart'; - -/// -/// Import -import 'package:flutter/material.dart'; - -/// -/// Part -part 'src/ai_barcode_widget.dart'; +/// Export +export 'src/ai_barcode_widget.dart'; diff --git a/lib/ai_barcode_web_plugin.dart b/lib/ai_barcode_web_plugin.dart deleted file mode 100644 index a7ef19b..0000000 --- a/lib/ai_barcode_web_plugin.dart +++ /dev/null @@ -1,126 +0,0 @@ -import 'dart:async'; - -import 'package:ai_barcode/src/scanner/ai_barcode_platform_scanner_interface.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_web_plugins/flutter_web_plugins.dart'; -import 'package:qr_flutter/qr_flutter.dart'; - -import 'src/ai_barcode_platform_interface.dart'; -import 'src/creator/ai_barcode_platform_creator_interface.dart'; - -/// -/// AiBarcodeWebPlugin -class AiBarcodeWebPlugin { - /// Registers this class as the default instance of [AiBarcodeWebPlugin]. - static void registerWith(Registrar registrar) { - // Registers plugins - AiBarcodeScannerWebPlugin.registerWith(registrar); - AiBarcodeCreatorWebPlugin.registerWith(registrar); - } -} - -/// AiBarcodeScannerWebPlugin -class AiBarcodeScannerWebPlugin extends AiBarcodeScannerPlatform { - /// - /// VideoElement -// static html.VideoElement _videoElement = html.VideoElement(); - - /// Registers this class as the default instance of [AiBarcodeWebPlugin]. - static void registerWith(Registrar registrar) { - AiBarcodeScannerPlatform.instance = AiBarcodeScannerWebPlugin(); -// -// // ignore: undefined_prefixed_name -// ui.platformViewRegistry -// .registerViewFactory(AiBarcodePlatform.viewIdOfScanner, (int viewId) { -// return _videoElement; -// }); - } - - @override - Widget buildScannerView(BuildContext context) { - Future.delayed(Duration(seconds: 2)) - .then((value) => onPlatformScannerViewCreated(0)); - return HtmlElementView( - key: UniqueKey(), - viewType: AiBarcodePlatform.viewIdOfScanner, - ); - } - - @override - startCamera() async { - //start camera -// html.window.navigator -// .getUserMedia(video: true) -// .then((html.MediaStream mediaStream) { -// _videoElement.srcObject = mediaStream; -// return mediaStream; -// }); - } - - @override - Future startCameraPreview() async { - //start camera preview -// _videoElement.play(); - return Future.delayed(Duration(seconds: 10)) - .then((value) => "after 10 second ,web code result doing!"); - } - - @override - stopCameraPreview() async { - //stop camera preview -// _videoElement.pause(); - } - - @override - stopCamera() async { - //stop camera and release camera -// _videoElement.srcObject.getTracks().forEach((element) { -// element.stop(); -// }); - } - - @override - toggleFlash() async {} - - @override - closeFlash() async {} - - @override - openFlash() async {} -} - -/// AiBarcodeCreatorWebPlugin -class AiBarcodeCreatorWebPlugin extends AiBarcodeCreatorPlatform { - /// - /// VideoElement -// static html.VideoElement _videoElement = html.VideoElement(); - - /// Registers this class as the default instance of [AiBarcodeCreatorWebPlugin]. - static void registerWith(Registrar registrar) { - AiBarcodeCreatorPlatform.instance = AiBarcodeCreatorWebPlugin(); -// -// // ignore: undefined_prefixed_name -// ui.platformViewRegistry -// .registerViewFactory(AiBarcodePlatform.viewIdOfCreator, (int viewId) { -// return _videoElement; -// }); - } - - @override - Widget buildCreatorView(BuildContext context) { - QrImage qrImage = QrImage( - data: AiBarcodeCreatorPlatform.instance.initialValueOfCreator, - version: QrVersions.auto, - size: 200.0, - ); - - return qrImage; - } - - @override - updateQRCodeValue(String value) { - AiBarcodeCreatorPlatform.instance.initialValueOfCreator = value; - notifyListeners(); - return super.updateQRCodeValue(value); - } -} diff --git a/lib/src/ai_barcode_platform_interface.dart b/lib/src/ai_barcode_platform_interface.dart deleted file mode 100644 index aa6a15e..0000000 --- a/lib/src/ai_barcode_platform_interface.dart +++ /dev/null @@ -1,34 +0,0 @@ -import 'package:flutter/services.dart'; - -/// -/// Channel -const MethodChannel _methodChannelScanner = - MethodChannel("view_type_id_scanner_view_method_channel"); - -const MethodChannel _methodChannelCreator = - MethodChannel("view_type_id_creator_view_method_channel"); -// EventChannel _eventChannel = -// EventChannel("view_type_id_scanner_view_event_channel"); - -/// View id of scanner widget -const String _viewIdOfScanner = "view_type_id_scanner_view"; - -/// View id of creator widget -const String _viewIdOfCreator = "view_type_id_creator_view"; - -///AiBarcodePlatform -/// -abstract class AiBarcodePlatform { - /// - /// MethodChannel - static MethodChannel get methodChannelScanner => _methodChannelScanner; - static MethodChannel get methodChannelCreator => _methodChannelCreator; - - /// - /// ViewId of scanner widget - static String get viewIdOfScanner => _viewIdOfScanner; - - /// - /// ViewId of creator widget - static String get viewIdOfCreator => _viewIdOfCreator; -} diff --git a/lib/src/ai_barcode_widget.dart b/lib/src/ai_barcode_widget.dart index 961c956..e335fd2 100644 --- a/lib/src/ai_barcode_widget.dart +++ b/lib/src/ai_barcode_widget.dart @@ -1,4 +1,7 @@ -part of '../ai_barcode.dart'; +import 'package:ai_barcode/src/creator/ai_barcode_mobile_creator_plugin.dart'; +import 'package:ai_barcode/src/scanner/ai_barcode_mobile_scanner_plugin.dart'; +import 'package:ai_barcode_platform_interface/ai_barcode_platform_interface.dart'; +import 'package:flutter/material.dart'; /// /// PlatformScannerWidget @@ -39,10 +42,6 @@ class _PlatformScannerWidgetState @override void initState() { super.initState(); - //Create - AiBarcodeScannerPlatform.instance.addListener(_widgetCreatedListener); - AiBarcodeScannerPlatform.instance.unsupportedPlatformDescription = - widget._unsupportedDescription; } /// @@ -64,6 +63,14 @@ class _PlatformScannerWidgetState @override Widget build(BuildContext context) { + TargetPlatform platform = Theme.of(context).platform; + if (platform == TargetPlatform.android || platform == TargetPlatform.iOS) { + AiBarcodeScannerPlatform.instance = AiBarcodeMobileScannerPlugin(); + } + //Create + AiBarcodeScannerPlatform.instance.addListener(_widgetCreatedListener); + AiBarcodeScannerPlatform.instance.unsupportedPlatformDescription = + widget._unsupportedDescription; return AiBarcodeScannerPlatform.instance.buildScannerView(context); } } @@ -169,12 +176,6 @@ class _PlatformAiBarcodeCreatorState @override void initState() { super.initState(); - //create - AiBarcodeCreatorPlatform.instance.unsupportedPlatformDescription = - widget._unsupportedDescription; - AiBarcodeCreatorPlatform.instance.initialValueOfCreator = - widget._initialValue; - AiBarcodeCreatorPlatform.instance.addListener(_creatorCreatedCallback); } _creatorCreatedCallback() { @@ -193,6 +194,16 @@ class _PlatformAiBarcodeCreatorState @override Widget build(BuildContext context) { + TargetPlatform platform = Theme.of(context).platform; + if (platform == TargetPlatform.android || platform == TargetPlatform.iOS) { + AiBarcodeCreatorPlatform.instance = AiBarcodeMobileCreatorPlugin(); + } + //create + AiBarcodeCreatorPlatform.instance.unsupportedPlatformDescription = + widget._unsupportedDescription; + AiBarcodeCreatorPlatform.instance.initialValueOfCreator = + widget._initialValue; + AiBarcodeCreatorPlatform.instance.addListener(_creatorCreatedCallback); return AiBarcodeCreatorPlatform.instance.buildCreatorView(context); } } diff --git a/lib/src/creator/ai_barcode_mobile_creator_plugin.dart b/lib/src/creator/ai_barcode_mobile_creator_plugin.dart index f502632..262b388 100644 --- a/lib/src/creator/ai_barcode_mobile_creator_plugin.dart +++ b/lib/src/creator/ai_barcode_mobile_creator_plugin.dart @@ -1,9 +1,6 @@ +import 'package:ai_barcode_platform_interface/ai_barcode_platform_interface.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:qr_flutter/qr_flutter.dart'; - -import '../ai_barcode_platform_interface.dart'; -import 'ai_barcode_platform_creator_interface.dart'; /// AiBarcodeMobileCreatorPlugin class AiBarcodeMobileCreatorPlugin extends AiBarcodeCreatorPlatform { @@ -48,12 +45,11 @@ class AiBarcodeMobileCreatorPlugin extends AiBarcodeCreatorPlatform { }, ); } else { - QrImage qrImage = QrImage( - data: AiBarcodeCreatorPlatform.instance.initialValueOfCreator, - version: QrVersions.auto, - size: 200.0, + return Center( + child: Text( + "$unsupportedPlatformDescription", + ), ); - return qrImage; } } diff --git a/lib/src/creator/ai_barcode_platform_creator_interface.dart b/lib/src/creator/ai_barcode_platform_creator_interface.dart deleted file mode 100644 index df1b288..0000000 --- a/lib/src/creator/ai_barcode_platform_creator_interface.dart +++ /dev/null @@ -1,90 +0,0 @@ -import 'package:ai_barcode/src/ai_barcode_platform_interface.dart'; -import 'package:flutter/material.dart'; - -import 'ai_barcode_mobile_creator_plugin.dart'; - -/// AiBarcodeCreatorPlatform -abstract class AiBarcodeCreatorPlatform extends ChangeNotifier - with AiBarcodePlatform { - /// Only mock implementations should set this to true. - /// - /// Mockito mocks are implementing this class with `implements` which is forbidden for anything - /// other than mocks (see class docs). This property provides a backdoor for mockito mocks to - /// skip the verification that the class isn't implemented with `implements`. - @visibleForTesting - bool get isMock => false; - - static AiBarcodeCreatorPlatform _instance = AiBarcodeMobileCreatorPlugin(); - - /// The default instance of [AiBarcodeCreatorPlatform] to use. - /// - /// Platform-specific plugins should override this with their own - /// platform-specific class that extends [AiBarcodeCreatorPlatform] when they - /// register themselves. - /// - static AiBarcodeCreatorPlatform get instance => _instance; - - String _initialValueOfCreator = "please set QRCode value"; - - String get initialValueOfCreator => _initialValueOfCreator; - - set initialValueOfCreator(String initialValue) { - if (initialValue == null || initialValue.isEmpty) { - return; - } - _initialValueOfCreator = initialValue; - } - - String _unsupportedPlatformDescription = - "Unsupported platforms, working hard to support"; - - String get unsupportedPlatformDescription => _unsupportedPlatformDescription; - - set unsupportedPlatformDescription(String text) { - if (text == null || text.isEmpty) { - return; - } - _unsupportedPlatformDescription = text; - } - - /// - /// Instance update - static set instance(AiBarcodeCreatorPlatform instance) { - if (!instance.isMock) { - try { - instance._verifyProvidesDefaultImplementations(); - } on NoSuchMethodError catch (_) { - throw AssertionError( - 'Platform interfaces must not be implemented with `implements`'); - } - } - _instance = instance; - } - - /// Returns a widget displaying - Widget buildCreatorView(BuildContext context) { - throw UnimplementedError('buildCreatorView() has not been implemented.'); - } - - /// - /// View created of creator widget - onPlatformCreatorViewCreated(int id) { - notifyListeners(); - } - - /// - /// Update QR Code value - updateQRCodeValue(String value) { - AiBarcodePlatform.methodChannelCreator.invokeMethod("updateQRCodeValue", { - "qrCodeContent": value, - }); - } - - // This method makes sure that AiBarcode isn't implemented with `implements`. - // - // See class doc for more details on why implementing this class is forbidden. - // - // This private method is called by the instance setter, which fails if the class is - // implemented with `implements`. - void _verifyProvidesDefaultImplementations() {} -} diff --git a/lib/src/scanner/ai_barcode_mobile_scanner_plugin.dart b/lib/src/scanner/ai_barcode_mobile_scanner_plugin.dart index dc41c1b..c9121b9 100644 --- a/lib/src/scanner/ai_barcode_mobile_scanner_plugin.dart +++ b/lib/src/scanner/ai_barcode_mobile_scanner_plugin.dart @@ -1,9 +1,7 @@ +import 'package:ai_barcode_platform_interface/ai_barcode_platform_interface.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import '../ai_barcode_platform_interface.dart'; -import 'ai_barcode_platform_scanner_interface.dart'; - /// /// AiBarcodeMobileScannerPlugin class AiBarcodeMobileScannerPlugin extends AiBarcodeScannerPlatform { @@ -44,43 +42,4 @@ class AiBarcodeMobileScannerPlugin extends AiBarcodeScannerPlatform { ); } } - -// Widget _barcodeCreator({BuildContext context}) { -// TargetPlatform targetPlatform = Theme.of(context).platform; -// if (targetPlatform == TargetPlatform.android) { -// return AndroidView( -// viewType: AiBarcodeScannerPlatform.viewIdOfCreator, -// creationParams: { -// "qrCodeContent": -// AiBarcodeScannerPlatform.instance.initialValueOfCreator, -// }, -// creationParamsCodec: StandardMessageCodec(), -// onPlatformViewCreated: (int id) { -// //created callback -// onPlatformCreatorViewCreated(id); -// //initial value -// AiBarcodeScannerPlatform.instance.updateQRCodeValue( -// AiBarcodeScannerPlatform.instance.initialValueOfCreator); -// }, -// ); -// } else if (targetPlatform == TargetPlatform.iOS) { -// return UiKitView( -// viewType: AiBarcodeScannerPlatform.viewIdOfCreator, -// creationParams: { -// "qrCodeContent": -// AiBarcodeScannerPlatform.instance.initialValueOfCreator, -// }, -// creationParamsCodec: StandardMessageCodec(), -// onPlatformViewCreated: (int id) { -// //created callback -// onPlatformCreatorViewCreated(id); -// //initial value -// AiBarcodeScannerPlatform.instance.updateQRCodeValue( -// AiBarcodeScannerPlatform.instance.initialValueOfCreator); -// }, -// ); -// } else { -// return Text("Unsupported platform!"); -// } -// } } diff --git a/lib/src/scanner/ai_barcode_platform_scanner_interface.dart b/lib/src/scanner/ai_barcode_platform_scanner_interface.dart deleted file mode 100644 index bab3455..0000000 --- a/lib/src/scanner/ai_barcode_platform_scanner_interface.dart +++ /dev/null @@ -1,138 +0,0 @@ -import 'package:ai_barcode/src/ai_barcode_platform_interface.dart'; -import 'package:flutter/material.dart'; - -import 'ai_barcode_mobile_scanner_plugin.dart'; - -/// AiBarcodeScannerPlatform -abstract class AiBarcodeScannerPlatform extends ChangeNotifier - with AiBarcodePlatform { - /// Only mock implementations should set this to true. - /// - /// Mockito mocks are implementing this class with `implements` which is forbidden for anything - /// other than mocks (see class docs). This property provides a backdoor for mockito mocks to - /// skip the verification that the class isn't implemented with `implements`. - @visibleForTesting - bool get isMock => false; - - static AiBarcodeScannerPlatform _instance = AiBarcodeMobileScannerPlugin(); - - bool _isStartCamera = false; - bool _isStartCameraPreview = false; - bool _isOpenFlash = false; - - /// The default instance of [AiBarcodeScannerPlatform] to use. - /// - /// Platform-specific plugins should override this with their own - /// platform-specific class that extends [AiBarcodeScannerPlatform] when they - /// register themselves. - /// - static AiBarcodeScannerPlatform get instance => _instance; - - /// - /// Whether start camera - bool get isStartCamera => _isStartCamera; - - /// - /// Whether start camera preview or start to recognize - bool get isStartCameraPreview => _isStartCameraPreview; - - /// - /// Whether open the flash - bool get isOpenFlash => _isOpenFlash; - - String _unsupportedPlatformDescription = - "Unsupported platforms, working hard to support"; - - String get unsupportedPlatformDescription => _unsupportedPlatformDescription; - - set unsupportedPlatformDescription(String text) { - if (text == null || text.isEmpty) { - return; - } - _unsupportedPlatformDescription = text; - } - - /// - /// Instance update - static set instance(AiBarcodeScannerPlatform instance) { - if (!instance.isMock) { - try { - instance._verifyProvidesDefaultImplementations(); - } on NoSuchMethodError catch (_) { - throw AssertionError( - 'Platform interfaces must not be implemented with `implements`'); - } - } - _instance = instance; - } - - /// Returns a widget displaying. - Widget buildScannerView(BuildContext context) { - throw UnimplementedError('buildView() has not been implemented.'); - } - - /// - /// View created of scanner widget - onPlatformScannerViewCreated(int id) { - notifyListeners(); - } - - /// - /// Start camera without open QRCode、BarCode scanner,this is just open camera. - startCamera() async { - _isStartCamera = true; - AiBarcodePlatform.methodChannelScanner.invokeMethod("startCamera"); - } - - /// - /// Stop camera. - stopCamera() async { - _isStartCamera = false; - AiBarcodePlatform.methodChannelScanner.invokeMethod("stopCamera"); - } - - /// - /// Start camera preview with open QRCode、BarCode scanner,this is open code scanner. - Future startCameraPreview() async { - _isStartCameraPreview = true; - return await AiBarcodePlatform.methodChannelScanner - .invokeMethod("resumeCameraPreview"); - } - - /// - /// Stop camera preview. - stopCameraPreview() async { - _isStartCameraPreview = false; - AiBarcodePlatform.methodChannelScanner.invokeMethod("stopCameraPreview"); - } - - /// - /// Open camera flash. - openFlash() async { - _isOpenFlash = true; - AiBarcodePlatform.methodChannelScanner.invokeMethod("openFlash"); - } - - /// - /// Close camera flash. - closeFlash() async { - _isOpenFlash = false; - AiBarcodePlatform.methodChannelScanner.invokeMethod("closeFlash"); - } - - /// - /// Toggle camera flash. - toggleFlash() async { - bool flash = isOpenFlash; - _isOpenFlash = !flash; - AiBarcodePlatform.methodChannelScanner.invokeMethod("toggleFlash"); - } - - // This method makes sure that AiBarcode isn't implemented with `implements`. - // - // See class doc for more details on why implementing this class is forbidden. - // - // This private method is called by the instance setter, which fails if the class is - // implemented with `implements`. - void _verifyProvidesDefaultImplementations() {} -} diff --git a/pubspec.lock b/pubspec.lock index ce1131f..495dd7c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,55 +1,69 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + ai_barcode_platform_interface: + dependency: "direct main" + description: + name: ai_barcode_platform_interface + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.0.0" + ai_barcode_web: + dependency: "direct main" + description: + name: ai_barcode_web + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.0.0" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "2.5.0-nullsafety.1" + version: "2.5.0" boolean_selector: dependency: transitive description: name: boolean_selector - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" characters: dependency: transitive description: name: characters - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0-nullsafety.3" + version: "1.1.0" charcode: dependency: transitive description: name: charcode - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" clock: dependency: transitive description: name: clock - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.15.0-nullsafety.3" + version: "1.15.0" fake_async: dependency: transitive description: name: fake_async - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" flutter: dependency: "direct main" description: flutter @@ -61,43 +75,50 @@ packages: source: sdk version: "0.0.0" flutter_web_plugins: - dependency: "direct main" + dependency: transitive description: flutter source: sdk version: "0.0.0" + js: + dependency: transitive + description: + name: js + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.6.3" matcher: dependency: transitive description: name: matcher - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "0.12.10-nullsafety.1" + version: "0.12.10" meta: dependency: "direct main" description: name: meta - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.8.0-nullsafety.1" + version: "1.8.0" qr: dependency: transitive description: name: qr - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "1.3.0" qr_flutter: - dependency: "direct main" + dependency: transitive description: name: qr_flutter - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted version: "3.2.0" sky_engine: @@ -109,58 +130,58 @@ packages: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.8.0-nullsafety.2" + version: "1.8.0" stack_trace: dependency: transitive description: name: stack_trace - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.10.0-nullsafety.1" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0-nullsafety.1" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0-nullsafety.1" + version: "1.1.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0-nullsafety.1" + version: "1.2.0" test_api: dependency: transitive description: name: test_api - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "0.2.19-nullsafety.2" + version: "0.2.19" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "1.3.0-nullsafety.3" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math - url: "https://pub.dartlang.org" + url: "https://pub.flutter-io.cn" source: hosted - version: "2.1.0-nullsafety.3" + version: "2.1.0" sdks: - dart: ">=2.10.0-110 <2.11.0" - flutter: ">=1.20.0 <2.0.0" + dart: ">=2.12.0-0.0 <3.0.0" + flutter: ">=1.20.0" diff --git a/pubspec.yaml b/pubspec.yaml index 99cf656..32c7e01 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,23 +1,20 @@ name: ai_barcode description: AiBarcode supports scanner、creator the one-dimensional bar code and two-dimensional bar code(Android 、iOS), and support the Scanner embedded in Flutter pages -version: 1.2.0 +version: 1.6.0 homepage: https://pdliuw.github.io/ repository: https://github.com/pdliuw/ai_barcode environment: sdk: ">=2.7.0 <3.0.0" - flutter: ">=1.20.0 <2.0.0" + flutter: ">=1.20.0" dependencies: flutter: sdk: flutter - # Support web plugin - flutter_web_plugins: - sdk: flutter meta: ^1.1.7 - # flutter create QRCode - qr_flutter: ^3.2.0 + ai_barcode_platform_interface: ^2.0.0 + ai_barcode_web: ^1.0.0 dev_dependencies: flutter_test: sdk: flutter @@ -46,8 +43,7 @@ flutter: macos: pluginClass: AiBarcodePlugin web: - pluginClass: AiBarcodeWebPlugin - fileName: ai_barcode_web_plugin.dart + default_package: ai_barcode_web # To add assets to your plugin package, add an assets section, like this: # assets: