diff --git a/.gitattributes b/.gitattributes
deleted file mode 100644
index dfe0770..0000000
--- a/.gitattributes
+++ /dev/null
@@ -1,2 +0,0 @@
-# Auto detect text files and perform LF normalization
-* text=auto
diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml
index 47ca5d0..ac17f4e 100644
--- a/.github/workflows/flutter.yml
+++ b/.github/workflows/flutter.yml
@@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
env:
JAVA_VERSION: "11.0"
- FLUTTER_VERSION: "3.13.0"
+ FLUTTER_VERSION: "3.19.3"
steps:
- name: Checkout repository
uses: actions/checkout@v4
diff --git a/.metadata b/.metadata
index f43a237..bc92567 100644
--- a/.metadata
+++ b/.metadata
@@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.
version:
- revision: "efbf63d9c66b9f6ec30e9ad4611189aa80003d31"
+ revision: "ba393198430278b6595976de84fe170f553cc728"
channel: "stable"
project_type: plugin
@@ -13,11 +13,11 @@ project_type: plugin
migration:
platforms:
- platform: root
- create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
- base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
+ create_revision: ba393198430278b6595976de84fe170f553cc728
+ base_revision: ba393198430278b6595976de84fe170f553cc728
- platform: android
- create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
- base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
+ create_revision: ba393198430278b6595976de84fe170f553cc728
+ base_revision: ba393198430278b6595976de84fe170f553cc728
# User provided section
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 77a9946..43342b1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,16 @@
# CHANGELOG
+## 3.0.1
+
+Fix handle space in scanned value
+dart format
+
+## 3.0.0
+
+Update gradle infrastructure
+Update Scanning method
+Refactoring
+
## 2.0.1
dart format
diff --git a/android/build.gradle b/android/build.gradle
index 9241430..2c2c002 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -8,7 +8,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.3.0'
+ classpath 'com.android.tools.build:gradle:7.3.1'
}
}
@@ -26,7 +26,7 @@ android {
namespace 'com.example.qrcode_barcode_scanner'
}
- compileSdkVersion 33
+ compileSdk 34
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
index 316b470..a2f47b6 100644
--- a/android/src/main/AndroidManifest.xml
+++ b/android/src/main/AndroidManifest.xml
@@ -1,3 +1,2 @@
-
+
diff --git a/example/.gitignore b/example/.gitignore
index 24476c5..29a3a50 100644
--- a/example/.gitignore
+++ b/example/.gitignore
@@ -27,7 +27,6 @@ migrate_working_dir/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
-.packages
.pub-cache/
.pub/
/build/
diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle
index 386ca01..36519a7 100644
--- a/example/android/app/build.gradle
+++ b/example/android/app/build.gradle
@@ -24,16 +24,15 @@ if (flutterVersionName == null) {
android {
namespace "com.example.qrcode_barcode_scanner_example"
- compileSdkVersion flutter.compileSdkVersion
- ndkVersion flutter.ndkVersion
+ compileSdk 34
+ ndkVersion '26.2.11394342'
compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility JavaVersion.VERSION_11
+ targetCompatibility JavaVersion.VERSION_11
}
defaultConfig {
- manifestPlaceholders = [applicationName: "android.app.Application"]
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.qrcode_barcode_scanner_example"
// You can update the following values to match your application needs.
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index e48c1c5..e3ee9b1 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -30,4 +30,15 @@
android:name="flutterEmbedding"
android:value="2" />
+
+
+
+
+
+
+
diff --git a/example/android/build.gradle b/example/android/build.gradle
index 34d0a89..bc157bd 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -1,16 +1,3 @@
-buildscript {
- ext.kotlin_version = '1.7.10'
- repositories {
- google()
- mavenCentral()
- }
-
- dependencies {
- classpath 'com.android.tools.build:gradle:8.1.1'
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- }
-}
-
allprojects {
repositories {
google()
diff --git a/example/android/gradle.properties b/example/android/gradle.properties
index b9a9a24..157da37 100644
--- a/example/android/gradle.properties
+++ b/example/android/gradle.properties
@@ -1,6 +1,5 @@
-org.gradle.jvmargs=-Xmx1536M
+org.gradle.jvmargs=-Xmx4G
android.useAndroidX=true
android.enableJetifier=true
-android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties
index 8bc9958..5e6b542 100644
--- a/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
diff --git a/example/android/settings.gradle b/example/android/settings.gradle
index 55c4ca8..ec9974b 100644
--- a/example/android/settings.gradle
+++ b/example/android/settings.gradle
@@ -10,11 +10,17 @@ pluginManagement {
includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
- plugins {
- id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false
+ repositories {
+ google()
+ mavenCentral()
+ gradlePluginPortal()
}
}
-include ":app"
+plugins {
+ id "dev.flutter.flutter-plugin-loader" version "1.0.0"
+ id "com.android.application" version '8.3.1' apply false
+ id "org.jetbrains.kotlin.android" version "1.7.10" apply false
+}
-apply from: "${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle/app_plugin_loader.gradle"
+include ":app"
diff --git a/example/integration_test/plugin_integration_test.dart b/example/integration_test/plugin_integration_test.dart
new file mode 100644
index 0000000..7377ac3
--- /dev/null
+++ b/example/integration_test/plugin_integration_test.dart
@@ -0,0 +1,25 @@
+// This is a basic Flutter integration test.
+//
+// Since integration tests run in a full Flutter application, they can interact
+// with the host side of a plugin implementation, unlike Dart unit tests.
+//
+// For more information about Flutter integration tests, please see
+// https://docs.flutter.dev/cookbook/testing/integration/introduction
+
+import 'package:flutter_test/flutter_test.dart';
+import 'package:integration_test/integration_test.dart';
+
+import 'package:qrcode_barcode_scanner/qrcode_barcode_scanner.dart';
+
+void main() {
+ IntegrationTestWidgetsFlutterBinding.ensureInitialized();
+
+ testWidgets('getPlatformVersion test', (WidgetTester tester) async {
+ final QrcodeBarcodeScanner plugin =
+ QrcodeBarcodeScanner(onScannedCallback: (String scannedCode) {});
+ final String? version = await plugin.getPlatformVersion();
+ // The version string depends on the host platform running the test, so
+ // just assert that some non-empty string is returned.
+ expect(version?.isNotEmpty, true);
+ });
+}
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 613464e..e716228 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -15,15 +15,19 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State {
String? _scanValue;
+ void setScannedValue(String value) {
+ setState(() {
+ _scanValue = value;
+ });
+ }
+
@override
void initState() {
super.initState();
QrcodeBarcodeScanner(
- onScannedCallback: (String value) => setState(
- () {
- _scanValue = value;
- },
- ),
+ onScannedCallback: (String value) {
+ setScannedValue(value);
+ },
);
}
@@ -34,11 +38,25 @@ class _MyAppState extends State {
appBar: AppBar(
title: const Text('Plugin example app'),
),
- body: Center(
- child: Text(
- 'Scan value: ${_scanValue ?? "none"}',
- style: const TextStyle(fontSize: 30),
- ),
+ body: Column(
+ children: [
+ Expanded(
+ child: Center(
+ child: Text(
+ "Scan value: ${_scanValue ?? 'none'}",
+ style: const TextStyle(fontSize: 30),
+ ),
+ ),
+ ),
+ ElevatedButton(
+ onPressed: () {
+ setState(() {
+ _scanValue = null;
+ });
+ },
+ child: const Text("Clear scanned"),
+ )
+ ],
),
),
);
diff --git a/example/pubspec.lock b/example/pubspec.lock
index 9465c0d..fe0cb51 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -37,18 +37,18 @@ packages:
dependency: transitive
description:
name: collection
- sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
+ sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
- version: "1.17.2"
+ version: "1.18.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
- sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be
+ sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d
url: "https://pub.dev"
source: hosted
- version: "1.0.5"
+ version: "1.0.6"
fake_async:
dependency: transitive
description:
@@ -61,10 +61,10 @@ packages:
dependency: transitive
description:
name: file
- sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
+ sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
- version: "6.1.4"
+ version: "7.0.0"
flutter:
dependency: "direct main"
description: flutter
@@ -79,10 +79,10 @@ packages:
dependency: "direct dev"
description:
name: flutter_lints
- sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4"
+ sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7
url: "https://pub.dev"
source: hosted
- version: "2.0.2"
+ version: "3.0.1"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -98,77 +98,101 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
+ leak_tracker:
+ dependency: transitive
+ description:
+ name: leak_tracker
+ sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
+ url: "https://pub.dev"
+ source: hosted
+ version: "10.0.0"
+ leak_tracker_flutter_testing:
+ dependency: transitive
+ description:
+ name: leak_tracker_flutter_testing
+ sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.1"
+ leak_tracker_testing:
+ dependency: transitive
+ description:
+ name: leak_tracker_testing
+ sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.1"
lints:
dependency: transitive
description:
name: lints
- sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
+ sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
url: "https://pub.dev"
source: hosted
- version: "2.1.1"
+ version: "3.0.0"
matcher:
dependency: transitive
description:
name: matcher
- sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
+ sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
- version: "0.12.16"
+ version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
- sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
+ sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
- version: "0.5.0"
+ version: "0.8.0"
meta:
dependency: transitive
description:
name: meta
- sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
+ sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
- version: "1.9.1"
+ version: "1.11.0"
path:
dependency: transitive
description:
name: path
- sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
+ sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
- version: "1.8.3"
+ version: "1.9.0"
platform:
dependency: transitive
description:
name: platform
- sha256: "4a451831508d7d6ca779f7ac6e212b4023dd5a7d08a27a63da33756410e32b76"
+ sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
url: "https://pub.dev"
source: hosted
- version: "3.1.0"
+ version: "3.1.4"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
- sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d
+ sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
- version: "2.1.6"
+ version: "2.1.8"
process:
dependency: transitive
description:
name: process
- sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09"
+ sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32"
url: "https://pub.dev"
source: hosted
- version: "4.2.4"
+ version: "5.0.2"
qrcode_barcode_scanner:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
- version: "2.0.1"
+ version: "3.0.0"
sky_engine:
dependency: transitive
description: flutter
@@ -186,18 +210,18 @@ packages:
dependency: transitive
description:
name: stack_trace
- sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
+ sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
- version: "1.11.0"
+ version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
- sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
+ sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
- version: "2.1.1"
+ version: "2.1.2"
string_scanner:
dependency: transitive
description:
@@ -226,10 +250,10 @@ packages:
dependency: transitive
description:
name: test_api
- sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
+ sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
- version: "0.6.0"
+ version: "0.6.1"
vector_math:
dependency: transitive
description:
@@ -242,26 +266,18 @@ packages:
dependency: transitive
description:
name: vm_service
- sha256: c620a6f783fa22436da68e42db7ebbf18b8c44b9a46ab911f666ff09ffd9153f
- url: "https://pub.dev"
- source: hosted
- version: "11.7.1"
- web:
- dependency: transitive
- description:
- name: web
- sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
+ sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
- version: "0.1.4-beta"
+ version: "13.0.0"
webdriver:
dependency: transitive
description:
name: webdriver
- sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49"
+ sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e"
url: "https://pub.dev"
source: hosted
- version: "3.0.2"
+ version: "3.0.3"
sdks:
- dart: ">=3.1.0 <4.0.0"
+ dart: ">=3.3.1 <4.0.0"
flutter: ">=3.3.0"
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index d6f62a1..0ad7df4 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -1,11 +1,11 @@
name: qrcode_barcode_scanner_example
-description: Demonstrates how to use the qrcode_barcode_scanner plugin.
+description: "Demonstrates how to use the qrcode_barcode_scanner plugin."
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
environment:
- sdk: '>=3.1.0 <4.0.0'
+ sdk: '>=3.3.1 <4.0.0'
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
@@ -27,7 +27,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
- cupertino_icons: ^1.0.2
+ cupertino_icons: ^1.0.6
dev_dependencies:
integration_test:
@@ -40,7 +40,7 @@ dev_dependencies:
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
- flutter_lints: ^2.0.0
+ flutter_lints: ^3.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
diff --git a/lib/qrcode_barcode_scanner.dart b/lib/qrcode_barcode_scanner.dart
index b04db50..6773260 100644
--- a/lib/qrcode_barcode_scanner.dart
+++ b/lib/qrcode_barcode_scanner.dart
@@ -31,86 +31,17 @@ class QrcodeBarcodeScanner {
/// A delayed action handler to handle delayed events.
final DelayedActionHandler _actionHandler;
- /// A map that maps key labels to their corresponding normal and shift values.
- final Map> _keyMappings = {
- "a": {"normal": "a", "shift": "A"},
- "b": {"normal": "b", "shift": "B"},
- "c": {"normal": "c", "shift": "C"},
- "d": {"normal": "d", "shift": "D"},
- "e": {"normal": "e", "shift": "E"},
- "f": {"normal": "f", "shift": "F"},
- "g": {"normal": "g", "shift": "G"},
- "h": {"normal": "h", "shift": "H"},
- "i": {"normal": "i", "shift": "I"},
- "j": {"normal": "j", "shift": "J"},
- "k": {"normal": "k", "shift": "K"},
- "l": {"normal": "l", "shift": "L"},
- "m": {"normal": "m", "shift": "M"},
- "n": {"normal": "n", "shift": "N"},
- "o": {"normal": "o", "shift": "O"},
- "p": {"normal": "p", "shift": "P"},
- "q": {"normal": "q", "shift": "Q"},
- "r": {"normal": "r", "shift": "R"},
- "s": {"normal": "s", "shift": "S"},
- "t": {"normal": "t", "shift": "T"},
- "u": {"normal": "u", "shift": "U"},
- "v": {"normal": "v", "shift": "V"},
- "w": {"normal": "w", "shift": "W"},
- "x": {"normal": "x", "shift": "X"},
- "y": {"normal": "y", "shift": "Y"},
- "z": {"normal": "z", "shift": "Z"},
- "1": {"normal": "1", "shift": "!"},
- "2": {"normal": "2", "shift": "@"},
- "3": {"normal": "3", "shift": "#"},
- "4": {"normal": "4", "shift": "\$"},
- "5": {"normal": "5", "shift": "%"},
- "6": {"normal": "6", "shift": "^"},
- "7": {"normal": "7", "shift": "&"},
- "8": {"normal": "8", "shift": "*"},
- "9": {"normal": "9", "shift": "("},
- "0": {"normal": "0", "shift": ")"},
- "`": {"normal": "`", "shift": "~"},
- "-": {"normal": "-", "shift": "_"},
- "=": {"normal": "=", "shift": "+"},
- "[": {"normal": "[", "shift": "{"},
- "]": {"normal": "]", "shift": "}"},
- "\\": {"normal": "\\", "shift": "|"},
- ";": {"normal": ";", "shift": ":"},
- "'": {"normal": "'", "shift": "\""},
- ",": {"normal": ",", "shift": "<"},
- ".": {"normal": ".", "shift": ">"},
- "/": {"normal": "/", "shift": "?"},
- "Tab": {"normal": "\t", "shift": null},
- "Enter": {"normal": "\n", "shift": null},
- " ": {"normal": " ", "shift": " "},
- };
-
Future getPlatformVersion() {
return QrcodeBarcodeScannerPlatform.instance.getPlatformVersion();
}
- /// Returns `true` if the [LogicalKeyboardKey] is the shift key.
- ///
- /// [key] is the logical keyboard key to check.
- bool isShift(LogicalKeyboardKey key) => key.synonyms.isNotEmpty
- ? key.synonyms.first == LogicalKeyboardKey.shift
- : false;
-
- /// Returns `true` if the [RawKeyEvent] is a key down event.
- ///
- /// [event] is the raw keyboard event to check.
- bool isKeyDown(RawKeyEvent event) => event is RawKeyDownEvent;
-
- /// The current modifier for the shift key.
- String _modifier = "normal";
-
/// Creates a new instance of [QrcodeBarcodeScanner].
///
/// The [onScannedCallback] parameter is a required callback function
/// that handles scanned barcodes.
QrcodeBarcodeScanner({required this.onScannedCallback})
: _actionHandler = DelayedActionHandler(hundredMs) {
- RawKeyboard.instance.addListener(_keyBoardCallback);
+ HardwareKeyboard.instance.addHandler(_keyBoardCallback);
_controller.stream.where((char) => char != null).listen(onKeyEvent);
}
@@ -125,7 +56,7 @@ class QrcodeBarcodeScanner {
_actionHandler.executeDelayed(() {
final String scannedCode =
_pressedKeys.isNotEmpty ? _pressedKeys.join() : "";
- onScannedCallback(scannedCode);
+ onScannedCallback(scannedCode.trim());
_pressedKeys.clear();
});
}
@@ -133,37 +64,17 @@ class QrcodeBarcodeScanner {
/// The callback function that is called when a keyboard event occurs.
///
- /// If [event] is a key down event, the corresponding key label is retrieved and added to the stream controller
- /// using [_getKeyForLogicalKey]. If the key is a shift key, [_modifier] is set to "shift" for the next key event.
- ///
- /// If [event] is a key up event, and the key is a shift key, [_modifier] is set to "normal".
- ///
/// [event] is the raw keyboard event that occurred.
- void _keyBoardCallback(RawKeyEvent event) {
- final LogicalKeyboardKey logicalKey = event.logicalKey;
- if (!isKeyDown(event)) {
- if (isShift(logicalKey)) {
- _modifier = "shift";
- } else {
- final String? key = _getKeyForLogicalKey(logicalKey);
- _controller.add(key);
- _modifier = "normal";
- }
+ bool _keyBoardCallback(KeyEvent event) {
+ if (event.character != "" &&
+ event.character != null &&
+ (List.of(event.character?.codeUnits ?? [])
+ ..removeWhere((element) => element == 0))
+ .isNotEmpty) {
+ _controller.add(event.character ?? "");
+ return true;
}
- }
-
- /// Returns the mapped key based on the given logical keyboard key [key].
- ///
- /// The mapped key is obtained from the [_keyMappings] map. The key mappings map
- /// maps each key label to a map that maps each modifier (e.g. "normal",
- /// "shift") to a corresponding value. If the key label is not found in the
- /// map, null is returned.
- ///
- /// [key] is the logical keyboard key.
- String? _getKeyForLogicalKey(LogicalKeyboardKey key) {
- final Map? mappedKey =
- _keyMappings[key.keyLabel.toLowerCase()];
- return mappedKey?[_modifier];
+ return false;
}
/// Disposes the resources used by the `QrcodeBarcodeScanner`.
@@ -171,7 +82,7 @@ class QrcodeBarcodeScanner {
/// Call this method when the `QrcodeBarcodeScanner` is no longer needed to release
/// any resources (such as keyboard listeners) it may have acquired.
void dispose() {
- RawKeyboard.instance.removeListener(_keyBoardCallback);
+ HardwareKeyboard.instance.removeHandler(_keyBoardCallback);
_controller.close();
}
}
diff --git a/pubspec.lock b/pubspec.lock
index 6dd9b42..66ffda5 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -37,10 +37,10 @@ packages:
dependency: transitive
description:
name: collection
- sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
+ sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
- version: "1.17.2"
+ version: "1.18.0"
fake_async:
dependency: transitive
description:
@@ -58,63 +58,87 @@ packages:
dependency: "direct dev"
description:
name: flutter_lints
- sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04
+ sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7
url: "https://pub.dev"
source: hosted
- version: "2.0.3"
+ version: "3.0.1"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
+ leak_tracker:
+ dependency: transitive
+ description:
+ name: leak_tracker
+ sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa"
+ url: "https://pub.dev"
+ source: hosted
+ version: "10.0.0"
+ leak_tracker_flutter_testing:
+ dependency: transitive
+ description:
+ name: leak_tracker_flutter_testing
+ sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.1"
+ leak_tracker_testing:
+ dependency: transitive
+ description:
+ name: leak_tracker_testing
+ sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.1"
lints:
dependency: transitive
description:
name: lints
- sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
+ sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
url: "https://pub.dev"
source: hosted
- version: "2.1.1"
+ version: "3.0.0"
matcher:
dependency: transitive
description:
name: matcher
- sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
+ sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
- version: "0.12.16"
+ version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
- sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
+ sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
- version: "0.5.0"
+ version: "0.8.0"
meta:
dependency: transitive
description:
name: meta
- sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
+ sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
- version: "1.9.1"
+ version: "1.11.0"
path:
dependency: transitive
description:
name: path
- sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
+ sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
- version: "1.8.3"
+ version: "1.9.0"
plugin_platform_interface:
dependency: "direct main"
description:
name: plugin_platform_interface
- sha256: da3fdfeccc4d4ff2da8f8c556704c08f912542c5fb3cf2233ed75372384a034d
+ sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
- version: "2.1.6"
+ version: "2.1.8"
sky_engine:
dependency: transitive
description: flutter
@@ -132,18 +156,18 @@ packages:
dependency: transitive
description:
name: stack_trace
- sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
+ sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
- version: "1.11.0"
+ version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
- sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
+ sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
- version: "2.1.1"
+ version: "2.1.2"
string_scanner:
dependency: transitive
description:
@@ -164,10 +188,10 @@ packages:
dependency: transitive
description:
name: test_api
- sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
+ sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
- version: "0.6.0"
+ version: "0.6.1"
vector_math:
dependency: transitive
description:
@@ -176,14 +200,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.4"
- web:
+ vm_service:
dependency: transitive
description:
- name: web
- sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
+ name: vm_service
+ sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
- version: "0.1.4-beta"
+ version: "13.0.0"
sdks:
- dart: ">=3.1.0 <4.0.0"
+ dart: ">=3.2.0-0 <4.0.0"
flutter: ">=3.3.0"
diff --git a/pubspec.yaml b/pubspec.yaml
index bc5fbf0..8def26a 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: qrcode_barcode_scanner
description: Plugins to manage the reading of QR code or barcode from an external device as a keyboard.
-version: 2.0.1
+version: 3.0.1
repository: "https://github.com/FrenkyDema/qrcode_barcode_scanner"
environment:
@@ -10,61 +10,20 @@ environment:
dependencies:
flutter:
sdk: flutter
- plugin_platform_interface: ^2.1.6
+ plugin_platform_interface: ^2.1.8
dev_dependencies:
flutter_test:
sdk: flutter
- flutter_lints: ^2.0.3
+ flutter_lints: ^3.0.1
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:
- # This section identifies this Flutter project as a plugin project.
- # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.)
- # which should be registered in the plugin registry. This is required for
- # using method channels.
- # The Android 'package' specifies package in which the registered class is.
- # This is required for using method channels on Android.
- # The 'ffiPlugin' specifies that native code should be built and bundled.
- # This is required for using `dart:ffi`.
- # All these are used by the tooling to maintain consistency when
- # adding or updating assets for this project.
plugin:
platforms:
android:
package: com.example.qrcode_barcode_scanner
pluginClass: QrcodeBarcodeScannerPlugin
-
- # To add assets to your plugin package, add an assets section, like this:
- # assets:
- # - images/a_dot_burr.jpeg
- # - images/a_dot_ham.jpeg
- #
- # For details regarding assets in packages, see
- # https://flutter.dev/assets-and-images/#from-packages
- #
- # An image asset can refer to one or more resolution-specific "variants", see
- # https://flutter.dev/assets-and-images/#resolution-aware
-
- # To add custom fonts to your plugin package, add a fonts section here,
- # in this "flutter" section. Each entry in this list should have a
- # "family" key with the font family name, and a "fonts" key with a
- # list giving the asset and other descriptors for the font. For
- # example:
- # fonts:
- # - family: Schyler
- # fonts:
- # - asset: fonts/Schyler-Regular.ttf
- # - asset: fonts/Schyler-Italic.ttf
- # style: italic
- # - family: Trajan Pro
- # fonts:
- # - asset: fonts/TrajanPro.ttf
- # - asset: fonts/TrajanPro_Bold.ttf
- # weight: 700
- #
- # For details regarding fonts in packages, see
- # https://flutter.dev/custom-fonts/#from-packages
diff --git a/test/qrcode_barcode_scanner_method_channel_test.dart b/test/qrcode_barcode_scanner_method_channel_test.dart
index 2c00718..a2903fe 100644
--- a/test/qrcode_barcode_scanner_method_channel_test.dart
+++ b/test/qrcode_barcode_scanner_method_channel_test.dart
@@ -3,12 +3,12 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:qrcode_barcode_scanner/qrcode_barcode_scanner_method_channel.dart';
void main() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+
MethodChannelQrcodeBarcodeScanner platform =
MethodChannelQrcodeBarcodeScanner();
const MethodChannel channel = MethodChannel('qrcode_barcode_scanner');
- TestWidgetsFlutterBinding.ensureInitialized();
-
setUp(() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
diff --git a/test/qrcode_barcode_scanner_test.dart b/test/qrcode_barcode_scanner_test.dart
index 6260dac..8bef774 100644
--- a/test/qrcode_barcode_scanner_test.dart
+++ b/test/qrcode_barcode_scanner_test.dart
@@ -1,8 +1,8 @@
import 'package:flutter_test/flutter_test.dart';
-import 'package:plugin_platform_interface/plugin_platform_interface.dart';
import 'package:qrcode_barcode_scanner/qrcode_barcode_scanner.dart';
-import 'package:qrcode_barcode_scanner/qrcode_barcode_scanner_method_channel.dart';
import 'package:qrcode_barcode_scanner/qrcode_barcode_scanner_platform_interface.dart';
+import 'package:qrcode_barcode_scanner/qrcode_barcode_scanner_method_channel.dart';
+import 'package:plugin_platform_interface/plugin_platform_interface.dart';
class MockQrcodeBarcodeScannerPlatform
with MockPlatformInterfaceMixin
@@ -20,12 +20,12 @@ void main() {
});
test('getPlatformVersion', () async {
- QrcodeBarcodeScanner testProjectPlugin =
+ QrcodeBarcodeScanner qrcodeBarcodeScannerPlugin =
QrcodeBarcodeScanner(onScannedCallback: (String scannedCode) {});
MockQrcodeBarcodeScannerPlatform fakePlatform =
MockQrcodeBarcodeScannerPlatform();
QrcodeBarcodeScannerPlatform.instance = fakePlatform;
- expect(await testProjectPlugin.getPlatformVersion(), '42');
+ expect(await qrcodeBarcodeScannerPlugin.getPlatformVersion(), '42');
});
}