├── .gitignore ├── .idea ├── .gitignore ├── libraries │ ├── Dart_SDK.xml │ └── Flutter_Plugins.xml ├── misc.xml ├── modules.xml ├── runConfigurations │ └── example_lib_main_dart.xml └── vcs.xml ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── android ├── .gitignore ├── .idea │ ├── .gitignore │ ├── gradle.xml │ ├── misc.xml │ ├── modules.xml │ └── vcs.xml ├── agconnect-services.json ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── com │ └── ara │ └── flutter_hms_scan_kit │ └── FlutterHmsScanKitPlugin.kt ├── example ├── .gitignore ├── .metadata ├── README.md ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── ara │ │ │ │ │ └── flutter_hms_scan_kit_example │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── values-night │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── assets │ └── images │ │ └── ic_logo.png ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Podfile.lock │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h ├── lib │ └── main.dart ├── pubspec.lock ├── pubspec.yaml └── test │ ├── Flutter插件发布步骤.md │ └── widget_test.dart ├── flutter_hms_scan_kit.iml ├── image └── scan_kit_example.jpg ├── ios ├── .gitignore ├── Assets │ └── .gitkeep ├── Classes │ ├── FlutterHmsScanKitPlugin.h │ ├── FlutterHmsScanKitPlugin.m │ └── SwiftFlutterHmsScanKitPlugin.swift └── flutter_hms_scan_kit.podspec ├── lib ├── flutter_hms_scan_kit.dart ├── scan_result.dart └── toast_utils.dart ├── pubspec.lock ├── pubspec.yaml └── test └── flutter_hms_scan_kit_test.dart /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .dart_tool/ 3 | 4 | .packages 5 | .pub/ 6 | 7 | build/ 8 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/libraries/Dart_SDK.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /.idea/libraries/Flutter_Plugins.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/runConfigurations/example_lib_main_dart.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: f4abaa0735eba4dfd8f33f73363911d63931fe03 8 | channel: stable 9 | 10 | project_type: plugin 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.1.4 2 | * 修复部分手机需要存储权限,获取不到导致打不开 3 | * 升级Android 扫码SDK 4 | 5 | ## 1.1.3 6 | * 兼容android13以上权限 7 | 8 | ## 1.1.2 9 | * 去除读取手机信息权限 10 | * 添加存储读取权限 11 | * 修复扫描打不开相册问题 12 | * 升级android 扫码 SDK 13 | 14 | ## 1.1.1 15 | * 去除存储权限 16 | 17 | ## 1.1.0 18 | * 修复无权限无提示和不启动扫描页面问题 19 | * 升级android 扫码 SDK 20 | 21 | ## 1.0.7 22 | * 添加异常捕获,修改MethodChannel名称 23 | 24 | ## 1.0.6 25 | * 添加测试Toast,修改MethodChannel名称 26 | 27 | ## 1.0.5 28 | * 修复ios scanType、scanTypeForm错误 29 | 30 | ## 1.0.4 31 | * 升级华为统一扫码SDK 32 | 33 | ## 1.0.3 34 | * 兼容Android 12 以上获取权限问题 35 | 36 | ## 1.0.2 37 | * 升级华为扫码版本 38 | 39 | ## 1.0.1 40 | * 修复Android多次打开扫描闪退问题 41 | * 优化多次启动扫描 42 | 43 | ## 1.0.0 44 | * 华为统一扫码服务嵌入Flutter 45 | * 支持扫描二维码和条形码 46 | * 支持码生成 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2021 XieXin 2 | 3 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 4 | 5 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 6 | 7 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | 9 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 10 | 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flutter华为扫码 2 | 3 | ## 华为统一扫码服务 4 | 5 | 华为统一扫码服务(Scan Kit)提供便捷的条形码和二维码扫描、解析、生成能力,帮助您快速构建应用内的扫码功能。 6 | 7 | 得益于华为在计算机视觉领域能力的积累,Scan Kit可以实现远距离码或小型码的检测和自动放大,同时针对常见复杂扫码场景(如反光、暗光、污损、模糊、柱面)做了针对性识别优化,提升扫码成功率与用户体验。 8 | 9 | Scan Kit支持Android和iOS系统集成。其中,Android系统集成Scan Kit后支持横屏扫码能力。 10 | 11 | ## 展示 12 | 13 | 14 | 15 | 16 | ## 支持的设备 17 | - Android 4.4及以上 18 | - iOS 11.0及以上 开发中 19 | - iOS 不支持armv7 20 | 21 | ## 扫码支持 22 | Scan Kit支持扫描13种全球主流的码制式。如果您的应用只处理部分特定的码制式,您也可以在setFormat中指定制式以便加快扫码速度,如果不指定,则默认处理所有支持的码制式。当前支持的码制式如下,后续将持续扩充。 23 | 24 | - 一维码:EAN-8、EAN-13、UPC-A、UPC-E、Codabar、Code 39、Code 93、Code 128、ITF-14 25 | - 二维码:QR Code、Data Matrix、PDF417、Aztec 26 | 27 | ## 码值解析 28 | Scan Kit可以直接返回码的原始内容,也可以针对使用特定内容格式编码的二维码/条形码进行分析并提取结构化数据,帮助开发者快速构建关联服务。已支持如下场景:联系人信息、Wi-Fi连接信息、网页、日历日程、ID卡、短信、电话、邮件、地理位置、商品条码、ISBN。 29 | 30 | ## 码生成 31 | 1. Scan Kit支持将字符串转换为一维码或二维码,目前已支持的码制式为EAN-8、EAN-13、UPC-A、UPC-E、Codabar、Code 39、Code 93、Code 128、ITF-14、QR Code、Data Matrix、PDF417、Aztec。开发者只需要提供字符串、码制式和尺寸要求即可获得相应的码图。 32 | 2. 目前iOS不支持logo二维码生成。 33 | 34 | ## 导入 35 | ~~~ 36 | dependencies: 37 | flutter_hms_scan_kit: ^x.y.z 38 | ~~~ 39 | 40 | ## 使用 41 | ~~~dart 42 | import 'package:flutter_hms_scan_kit/flutter_hms_scan_kit.dart'; 43 | import 'package:flutter_hms_scan_kit/scan_result.dart'; 44 | 45 | ///扫码 46 | ScanResult? _scanResult; 47 | ///方式一 48 | Future scan() async { 49 | _scanResult = await FlutterHmsScanKit.scan; 50 | setState(() {}); 51 | } 52 | ///方式二 53 | Future scan() async { 54 | _scanResult = await FlutterHmsScanKit.startScan(); 55 | setState(() {}); 56 | } 57 | 58 | ///扫码结果 59 | class ScanResult { 60 | /// 扫码结果信息 61 | ScanType? scanType; 62 | /// 条码内容类型 63 | ScanTypeFormat? scanTypeForm; 64 | /// 获取条码原始的全部码值信息。只有当条码编码格式为UTF-8时才可以使用 65 | String? value; 66 | /// 非UTF-8格式的条码使用 67 | List? valueByte; 68 | } 69 | 70 | ///生成条码 71 | Future generateCode() async { 72 | var bytes = await rootBundle.load("assets/images/ic_logo.png"); 73 | _code = await FlutterHmsScanKit.generateCode( 74 | content: "这是条码", 75 | type: ScanType.QRCODE_SCAN_TYPE, 76 | width: 300, 77 | height: 300, 78 | color: "#7CB342", 79 | logo: bytes.buffer.asUint8List(), 80 | ); 81 | setState(() {}); 82 | } 83 | ~~~ 84 | 85 | ## iOS权限配置 86 | 使用Scan Kit时,开发者需要先添加相应的权限。 87 | - 构建相机扫码功能,需要添加“Camera Usage Description”(相机权限)。 88 | - 构建导入图片扫码功能,需要添加“Photo Library Usage Description”(读取相册权限)。 89 | 90 | 在info.plist文件,用Source Code打开并添加如下内容: 91 | ~~~ 92 | NSCameraUsageDescription 93 | 请允许APP访问您的相机 94 | NSPhotoLibraryUsageDescription 95 | 请允许APP访问您的相册 96 | ~~~ 97 | 98 | ## 扫码结果类型 99 | ~~~dart 100 | ///扫码结果信息 101 | enum ScanTypeFormat { 102 | ///无法识别扫描条码类型。 103 | FORMAT_UNKNOWN, //-1 104 | ///扫码类型设置-扫描所有条码类型。 105 | ALL_SCAN_TYPE, //0 106 | ///QR Code条码类型。 107 | QRCODE_SCAN_TYPE, //1 108 | ///Aztec条码类型。 109 | AZTEC_SCAN_TYPE, //2 110 | ///Data Matrix条码类型。 111 | DATAMATRIX_SCAN_TYPE, //4 112 | ///PDF417条码类型。 113 | PDF417_SCAN_TYPE, //8 114 | ///Code 39条码类型。 115 | CODE39_SCAN_TYPE, //16 116 | ///Code 93条码类型。 117 | CODE93_SCAN_TYPE, //32 118 | ///Code 128条码类型。 119 | CODE128_SCAN_TYPE, //64 120 | ///EAN-13条码类型。 121 | EAN13_SCAN_TYPE, //128 122 | ///EAN-8条码类型。 123 | EAN8_SCAN_TYPE, //256 124 | ///ITF-14条码类型。 125 | ITF14_SCAN_TYPE, //512 126 | ///UPC-A条码类型。 127 | UPCCODE_A_SCAN_TYPE, //1024 128 | ///UPC-E条码类型。 129 | UPCCODE_E_SCAN_TYPE, //2048 130 | ///Codabar条码类型。 131 | CODABAR_SCAN_TYPE, //4096 132 | } 133 | ~~~ 134 | 135 | ## 条码内容类型 136 | ~~~dart 137 | ///条码内容类型 138 | enum ScanType { 139 | ///商品条码 140 | ARTICLE_NUMBER_FORM, //1001 141 | ///邮件 142 | EMAIL_CONTENT_FORM, //1002 143 | ///电话 144 | TEL_PHONE_NUMBER_FORM, //1003 145 | ///文本 146 | PURE_TEXT_FORM, //1004 147 | ///短信 148 | SMS_FORM, //1005 149 | ///网页 150 | URL_FORM, //1006 151 | ///Wi-Fi连接信息 152 | WIFI_CONNECT_INFO_FORM, //1007 153 | ///事件 154 | EVENT_INFO_FORM, //1008 155 | ///联系人信息 156 | CONTACT_DETAIL_FORM, //1009 157 | ///设备信息 158 | DRIVER_INFO_FORM, //10010 159 | ///地理位置 160 | LOCATION_COORDINATE_FORM, //10011 161 | ///ISBN 162 | ISBN_NUMBER_FORM, //10012 163 | ///书签 164 | BOOK_MARK_FORM, //10013 165 | ///车辆信息 166 | VEHICLE_INFO_FORM, //10014 167 | } 168 | ~~~ 169 | 170 | ## SDK数据安全说明 171 | Scan Kit不会收集个人数据,Android平台只会基于运营目的收集BI(Business Intelligence)数据,iOS平台不收集任何数据 。 172 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /android/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /android/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 13 | 14 | -------------------------------------------------------------------------------- /android/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /android/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /android/agconnect-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "agcgw_all":{ 3 | "CN":"connect-drcn.hispace.hicloud.com", 4 | "CN_back":"connect-drcn.dbankcloud.cn", 5 | "DE":"connect-dre.hispace.hicloud.com", 6 | "DE_back":"connect-dre.dbankcloud.cn", 7 | "RU":"connect-drru.hispace.hicloud.com", 8 | "RU_back":"connect-drru.dbankcloud.cn", 9 | "SG":"connect-dra.hispace.hicloud.com", 10 | "SG_back":"connect-dra.dbankcloud.cn" 11 | }, 12 | "client":{ 13 | "cp_id":"2850086000490971405", 14 | "product_id":"736430079245837997", 15 | "client_id":"664920220820833344", 16 | "client_secret":"D1DF6838C8B35B5AC15902C134E91062940C9FD5DE6D9B49C177A350F6718FC9", 17 | "project_id":"736430079245837997", 18 | "app_id":"104494907", 19 | "api_key":"CgB6e3x92Vl1jI7fT/TI7j+ASKSEdh2LSxlWLzAihGTebdHHcTUlV1IM9jN9lnUfhXantdQHO6e2eZehelVMpFsh", 20 | "package_name":"com.ara._example" 21 | }, 22 | "oauth_client":{ 23 | "client_id":"104494907", 24 | "client_type":1 25 | }, 26 | "app_info":{ 27 | "app_id":"104494907", 28 | "package_name":"com.ara._example" 29 | }, 30 | "configuration_version":"3.0", 31 | "appInfos":[ 32 | { 33 | "package_name":"com.ara._example", 34 | "client":{ 35 | "app_id":"104494907" 36 | }, 37 | "app_info":{ 38 | "package_name":"com.ara._example", 39 | "app_id":"104494907" 40 | }, 41 | "oauth_client":{ 42 | "client_type":1, 43 | "client_id":"104494907" 44 | } 45 | } 46 | ] 47 | } -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.ara.flutter_hms_scan_kit' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | ext.kotlin_version = '1.8.22' 6 | repositories { 7 | google() 8 | jcenter() 9 | // 配置HMS Core SDK的Maven仓地址。 10 | maven { url 'https://developer.huawei.com/repo/' } 11 | } 12 | 13 | dependencies { 14 | classpath 'com.android.tools.build:gradle:7.1.2' 15 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 16 | // 增加agcp插件配置,推荐您使用最新版本的agcp插件。 17 | classpath 'com.huawei.agconnect:agcp:1.6.0.300' 18 | } 19 | } 20 | 21 | rootProject.allprojects { 22 | repositories { 23 | google() 24 | jcenter() 25 | // 配置HMS Core SDK的Maven仓地址。 26 | maven { url 'https://developer.huawei.com/repo/' } 27 | } 28 | } 29 | 30 | apply plugin: 'com.android.library' 31 | apply plugin: 'kotlin-android' 32 | apply plugin: 'com.huawei.agconnect' 33 | android { 34 | compileSdkVersion 33 35 | 36 | sourceSets { 37 | main.java.srcDirs += 'src/main/kotlin' 38 | } 39 | defaultConfig { 40 | minSdkVersion 16 41 | } 42 | } 43 | 44 | dependencies { 45 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 46 | implementation 'com.huawei.hms:scanplus:2.12.0.301' 47 | } 48 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 6 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'flutter_hms_scan_kit' 2 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/ara/flutter_hms_scan_kit/FlutterHmsScanKitPlugin.kt: -------------------------------------------------------------------------------- 1 | package com.ara.flutter_hms_scan_kit 2 | 3 | import android.Manifest 4 | import android.app.Activity 5 | import android.content.Intent 6 | import android.content.pm.PackageManager 7 | import android.graphics.Bitmap 8 | import android.graphics.BitmapFactory 9 | import android.graphics.Color 10 | import android.os.Build 11 | import android.util.Log 12 | import android.view.Gravity 13 | import android.widget.Toast 14 | import androidx.annotation.NonNull 15 | import androidx.core.app.ActivityCompat 16 | import com.huawei.hms.hmsscankit.ScanUtil 17 | import com.huawei.hms.hmsscankit.WriterException 18 | import com.huawei.hms.ml.scan.HmsBuildBitmapOption 19 | import com.huawei.hms.ml.scan.HmsScan 20 | import com.huawei.hms.ml.scan.HmsScanAnalyzerOptions 21 | import io.flutter.embedding.engine.plugins.FlutterPlugin 22 | import io.flutter.embedding.engine.plugins.activity.ActivityAware 23 | import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding 24 | import io.flutter.plugin.common.MethodCall 25 | import io.flutter.plugin.common.MethodChannel 26 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler 27 | import io.flutter.plugin.common.MethodChannel.Result 28 | import java.io.ByteArrayOutputStream 29 | 30 | 31 | /** FlutterHmsScanKitPlugin */ 32 | class FlutterHmsScanKitPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { 33 | private val TAG: String = FlutterHmsScanKitPlugin::javaClass.name 34 | private val CAMERA_REQ_CODE = 111 35 | private val STORAGE_REQ_CODE = 112 36 | private val REQUEST_CODE_SCAN = 0X01 37 | 38 | /// The MethodChannel that will the communication between Flutter and native Android 39 | /// 40 | /// This local reference serves to register the plugin with the Flutter Engine and unregister it 41 | /// when the Flutter Engine is detached from the Activity 42 | private lateinit var channel: MethodChannel 43 | 44 | private var result: Result? = null 45 | private var activity: Activity? = null 46 | 47 | override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { 48 | channel = 49 | MethodChannel(flutterPluginBinding.binaryMessenger, "Aar/FlutterHmsScanKit") 50 | channel.setMethodCallHandler(this) 51 | } 52 | 53 | override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { 54 | this.result = result 55 | var isToast: Boolean? = call.argument("isToast") 56 | if (isToast == null) isToast = false; 57 | if (isToast) showToast("插件通信正常") 58 | if (call.method == "getPlatformVersion") { 59 | if (isToast) showToast("开始获取系统版本") 60 | result.success("Android ${android.os.Build.VERSION.RELEASE}") 61 | } else if (call.method == "startScan") {//扫码 62 | if (isToast) showToast("开始扫码") 63 | requestPermission() 64 | } else if (call.method == "generateCode") {//生产条码 65 | if (isToast) showToast("开始生成二维码") 66 | val content: String? = call.argument("content") 67 | val type: Int? = call.argument("type") 68 | val width: Int? = call.argument("width") 69 | val height: Int? = call.argument("height") 70 | val color: String? = call.argument("color") 71 | val logo: ByteArray? = call.argument("logo") 72 | generateCode(content, type, width, height, color, logo) 73 | } else { 74 | result.notImplemented() 75 | } 76 | } 77 | 78 | override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { 79 | channel.setMethodCallHandler(null) 80 | } 81 | 82 | override fun onAttachedToActivity(binding: ActivityPluginBinding) { 83 | activity = binding.activity 84 | onRequestPermissionsResultListener(binding) 85 | onActivityResultListener(binding) 86 | } 87 | 88 | override fun onDetachedFromActivityForConfigChanges() { 89 | } 90 | 91 | override fun onReattachedToActivityForConfigChanges(binding: ActivityPluginBinding) { 92 | } 93 | 94 | override fun onDetachedFromActivity() { 95 | } 96 | 97 | /** 98 | * Apply for permissions. 99 | */ 100 | private fun requestPermission() { 101 | if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S) { 102 | ActivityCompat.requestPermissions( 103 | activity!!, arrayOf( 104 | Manifest.permission.CAMERA, 105 | Manifest.permission.READ_MEDIA_IMAGES, 106 | Manifest.permission.READ_MEDIA_VIDEO, 107 | Manifest.permission.READ_MEDIA_AUDIO, 108 | ), 109 | CAMERA_REQ_CODE 110 | ) 111 | } else { 112 | ActivityCompat.requestPermissions( 113 | activity!!, arrayOf( 114 | Manifest.permission.CAMERA, 115 | Manifest.permission.READ_EXTERNAL_STORAGE, 116 | ), 117 | CAMERA_REQ_CODE 118 | ) 119 | } 120 | } 121 | 122 | private fun showToast(text: String) { 123 | val toast = Toast.makeText(activity, text, Toast.LENGTH_SHORT) 124 | toast.setGravity(Gravity.CENTER, 0, 0) 125 | toast.show() 126 | } 127 | 128 | private fun onRequestPermissionsResultListener(binding: ActivityPluginBinding) { 129 | binding.addRequestPermissionsResultListener { requestCode: Int, permissions: Array?, grantResults: IntArray? -> 130 | if (permissions == null || grantResults == null) { 131 | println("权限是否为空,permissions=${permissions == null},grantResults=${grantResults == null}") 132 | showToast("权限是否为空,permissions=${permissions == null},grantResults=${grantResults == null}") 133 | return@addRequestPermissionsResultListener false 134 | } 135 | println("permissions size ${permissions.size}") 136 | println("grantResults size ${grantResults.size}") 137 | 138 | if (grantResults[0] != PackageManager.PERMISSION_GRANTED) { 139 | println("请到“设置-权限”授予拍照权限") 140 | showToast("请到“设置-权限”授予拍照权限") 141 | return@addRequestPermissionsResultListener false 142 | } 143 | if (Build.VERSION.SDK_INT > Build.VERSION_CODES.S_V2) { 144 | if (grantResults.size > 1 && grantResults[1] != PackageManager.PERMISSION_GRANTED && 145 | grantResults.size > 2 && grantResults[2] != PackageManager.PERMISSION_GRANTED && 146 | grantResults.size > 3 && grantResults[3] != PackageManager.PERMISSION_GRANTED) { 147 | println("请到“设置-权限”授予读存储(媒体和文件)权限") 148 | showToast("请到“设置-权限”授予读存储(媒体和文件)权限") 149 | return@addRequestPermissionsResultListener false 150 | } 151 | } else { 152 | if (grantResults.size > 1 && grantResults[1] != PackageManager.PERMISSION_GRANTED) { 153 | println("请到“设置-权限”授予读取权限") 154 | showToast("请到“设置-权限”授予读取权限") 155 | return@addRequestPermissionsResultListener false 156 | } 157 | } 158 | 159 | //Default View Mode 160 | if (requestCode == CAMERA_REQ_CODE) { 161 | ScanUtil.startScan( 162 | activity, 163 | REQUEST_CODE_SCAN, 164 | HmsScanAnalyzerOptions.Creator().create() 165 | ) 166 | } 167 | true 168 | } 169 | } 170 | 171 | private fun onActivityResultListener(binding: ActivityPluginBinding) { 172 | binding.addActivityResultListener { requestCode: Int, resultCode: Int, data: Intent? -> 173 | if (resultCode != Activity.RESULT_OK || data == null) { 174 | return@addActivityResultListener false 175 | } 176 | //Default View 177 | try { 178 | if (requestCode == REQUEST_CODE_SCAN) { 179 | val obj: HmsScan? = data.getParcelableExtra(ScanUtil.RESULT) 180 | if (obj != null) { 181 | val map: MutableMap = HashMap() 182 | map["scanTypeForm"] = obj.getScanType() 183 | map["scanType"] = obj.getScanTypeForm() 184 | //获取条码原始的全部码值信息。只有当条码编码格式为UTF-8时才可以使用 185 | if (obj.getOriginalValue() != null) 186 | map["value"] = obj.getOriginalValue() 187 | //非UTF-8格式的条码使用 188 | if (obj.getOriginValueByte() != null) 189 | map["valueByte"] = obj.getOriginValueByte() 190 | result?.success(map) 191 | } else { 192 | result?.success(HashMap()) 193 | } 194 | } 195 | } catch (e: Exception) { 196 | Log.e(TAG, "Failed to handle method call", e); 197 | } 198 | false 199 | } 200 | } 201 | 202 | /** 203 | * 生成条码 204 | */ 205 | private fun generateCode( 206 | content: String? = "", type: Int?, 207 | width: Int?, height: Int?, color: String?, 208 | logo: ByteArray? 209 | ) { 210 | if (content == null || content.isEmpty()) { 211 | Toast.makeText(activity, "请输入生成内容", Toast.LENGTH_SHORT).show() 212 | return 213 | } 214 | try { 215 | //Generate the barcode. 216 | val options = HmsBuildBitmapOption.Creator() 217 | .setBitmapBackgroundColor(Color.WHITE) 218 | if (color != null && color.length == 7) { 219 | val codeColor: Int = Color.parseColor(color) 220 | options.setBitmapColor(codeColor) 221 | } 222 | if (logo != null && logo.isNotEmpty()) { 223 | options.setQRLogoBitmap(byte2Bitmap(logo)) 224 | } 225 | val bitmap = ScanUtil.buildBitmap( 226 | content, type ?: HmsScan.QRCODE_SCAN_TYPE, 227 | width ?: 500, height ?: 500, options.create() 228 | ) 229 | val map: MutableMap = HashMap() 230 | map["code"] = bitmap2Byte(bitmap) 231 | result?.success(map) 232 | } catch (e: WriterException) { 233 | Log.e(TAG, "参数错误", e); 234 | Toast.makeText(activity, "参数错误!", Toast.LENGTH_SHORT).show() 235 | } catch (e: Exception) { 236 | Log.e(TAG, "Failed to handle method call", e); 237 | } 238 | } 239 | 240 | private fun bitmap2Byte(bitmap: Bitmap): ByteArray { 241 | val baos = ByteArrayOutputStream() 242 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos) 243 | bitmap.recycle() 244 | val results = baos.toByteArray(); 245 | baos.close() 246 | return results 247 | } 248 | 249 | private fun byte2Bitmap(bytes: ByteArray): Bitmap { 250 | return BitmapFactory.decodeByteArray(bytes, 0, bytes.size) 251 | } 252 | } 253 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | **/ios/Flutter/.last_build_id 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Web related 35 | lib/generated_plugin_registrant.dart 36 | 37 | # Symbolication related 38 | app.*.symbols 39 | 40 | # Obfuscation related 41 | app.*.map.json 42 | 43 | # Android Studio will place build artifacts here 44 | /android/app/debug 45 | /android/app/profile 46 | /android/app/release 47 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: f4abaa0735eba4dfd8f33f73363911d63931fe03 8 | channel: stable 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # _example 2 | 3 | Demonstrates how to use the flutter_hms_scan_kit plugin. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 33 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | defaultConfig { 36 | applicationId "com.ara.flutter_hms_scan_kit_example" 37 | minSdkVersion 19 38 | targetSdkVersion 33 39 | versionCode flutterVersionCode.toInteger() 40 | versionName flutterVersionName 41 | } 42 | 43 | buildTypes { 44 | release { 45 | // Signing with the debug keys for now, so `flutter run --release` works. 46 | signingConfig signingConfigs.debug 47 | } 48 | } 49 | } 50 | 51 | flutter { 52 | source '../..' 53 | } 54 | 55 | dependencies { 56 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 57 | } 58 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 7 | 15 | 19 | 22 | 27 | 30 | 31 | 32 | 33 | 34 | 35 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/ara/flutter_hms_scan_kit_example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.ara.flutter_hms_scan_kit_example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.1.2' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | project.evaluationDependsOn(':app') 25 | } 26 | 27 | tasks.register("clean", Delete) { 28 | delete rootProject.buildDir 29 | } 30 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /example/assets/images/ic_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/assets/images/ic_logo.png -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/ephemeral/ 22 | Flutter/app.flx 23 | Flutter/app.zip 24 | Flutter/flutter_assets/ 25 | Flutter/flutter_export_environment.sh 26 | ServiceDefinitions.json 27 | Runner/GeneratedPluginRegistrant.* 28 | 29 | # Exceptions to above rules. 30 | !default.mode1v3 31 | !default.mode2v3 32 | !default.pbxuser 33 | !default.perspectivev3 34 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 8.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | platform :ios, '11.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - flutter_hms_scan_kit (1.0.4): 4 | - Flutter 5 | - ScanKitFrameWork (~> 1.1.0.306) 6 | - ScanKitFrameWork (1.1.0.306) 7 | 8 | DEPENDENCIES: 9 | - Flutter (from `Flutter`) 10 | - flutter_hms_scan_kit (from `.symlinks/plugins/flutter_hms_scan_kit/ios`) 11 | 12 | SPEC REPOS: 13 | trunk: 14 | - ScanKitFrameWork 15 | 16 | EXTERNAL SOURCES: 17 | Flutter: 18 | :path: Flutter 19 | flutter_hms_scan_kit: 20 | :path: ".symlinks/plugins/flutter_hms_scan_kit/ios" 21 | 22 | SPEC CHECKSUMS: 23 | Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a 24 | flutter_hms_scan_kit: 7d1c884b64fb60f70cf38295f2fba41c2d9fee5b 25 | ScanKitFrameWork: 0f41951fffe11820b6e530b947bc1a26725daac6 26 | 27 | PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d 28 | 29 | COCOAPODS: 1.10.1 30 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 51; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 22C20F7826FC8F1E00C06FA8 /* testimage.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 22C20F7726FC8F1E00C06FA8 /* testimage.jpg */; }; 12 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 13 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 14 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 15 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 16 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 17 | F3DD4F316E0201E7C6CA521C /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C982958CFDCB8DC9A6B95EB2 /* Pods_Runner.framework */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXCopyFilesBuildPhase section */ 21 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 22 | isa = PBXCopyFilesBuildPhase; 23 | buildActionMask = 2147483647; 24 | dstPath = ""; 25 | dstSubfolderSpec = 10; 26 | files = ( 27 | ); 28 | name = "Embed Frameworks"; 29 | runOnlyForDeploymentPostprocessing = 0; 30 | }; 31 | /* End PBXCopyFilesBuildPhase section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 35 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 36 | 22C20F7726FC8F1E00C06FA8 /* testimage.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; name = testimage.jpg; path = "../../../../../../Library/Containers/com.tencent.xinWeChat/Data/Library/Application Support/com.tencent.xinWeChat/2.0b4.0.9/a5c127589b64fb116c30a76a5ff7bf20/Message/MessageTemp/77741b4b68af6adb81b272fdbce58009/Image/testimage.jpg"; sourceTree = ""; }; 37 | 2525CED8F230DEAFBE4B49C4 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 38 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 39 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 40 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 41 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 42 | 8BC6422039662927E6BDAFEF /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 43 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 44 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 45 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 46 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 47 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 48 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 49 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 50 | C982958CFDCB8DC9A6B95EB2 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | E2EA15BAFF465343977BF97A /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 52 | /* End PBXFileReference section */ 53 | 54 | /* Begin PBXFrameworksBuildPhase section */ 55 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 56 | isa = PBXFrameworksBuildPhase; 57 | buildActionMask = 2147483647; 58 | files = ( 59 | F3DD4F316E0201E7C6CA521C /* Pods_Runner.framework in Frameworks */, 60 | ); 61 | runOnlyForDeploymentPostprocessing = 0; 62 | }; 63 | /* End PBXFrameworksBuildPhase section */ 64 | 65 | /* Begin PBXGroup section */ 66 | 045481D93798E1F7B7ADBD7D /* Pods */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 8BC6422039662927E6BDAFEF /* Pods-Runner.debug.xcconfig */, 70 | E2EA15BAFF465343977BF97A /* Pods-Runner.release.xcconfig */, 71 | 2525CED8F230DEAFBE4B49C4 /* Pods-Runner.profile.xcconfig */, 72 | ); 73 | path = Pods; 74 | sourceTree = ""; 75 | }; 76 | 57E70773F17E5FD8C37182E8 /* Frameworks */ = { 77 | isa = PBXGroup; 78 | children = ( 79 | C982958CFDCB8DC9A6B95EB2 /* Pods_Runner.framework */, 80 | ); 81 | name = Frameworks; 82 | sourceTree = ""; 83 | }; 84 | 9740EEB11CF90186004384FC /* Flutter */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 88 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 89 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 90 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 91 | ); 92 | name = Flutter; 93 | sourceTree = ""; 94 | }; 95 | 97C146E51CF9000F007C117D = { 96 | isa = PBXGroup; 97 | children = ( 98 | 9740EEB11CF90186004384FC /* Flutter */, 99 | 97C146F01CF9000F007C117D /* Runner */, 100 | 97C146EF1CF9000F007C117D /* Products */, 101 | 045481D93798E1F7B7ADBD7D /* Pods */, 102 | 57E70773F17E5FD8C37182E8 /* Frameworks */, 103 | ); 104 | sourceTree = ""; 105 | }; 106 | 97C146EF1CF9000F007C117D /* Products */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 97C146EE1CF9000F007C117D /* Runner.app */, 110 | ); 111 | name = Products; 112 | sourceTree = ""; 113 | }; 114 | 97C146F01CF9000F007C117D /* Runner */ = { 115 | isa = PBXGroup; 116 | children = ( 117 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 118 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 119 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 120 | 97C147021CF9000F007C117D /* Info.plist */, 121 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 122 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 123 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 124 | 22C20F7726FC8F1E00C06FA8 /* testimage.jpg */, 125 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 126 | ); 127 | path = Runner; 128 | sourceTree = ""; 129 | }; 130 | /* End PBXGroup section */ 131 | 132 | /* Begin PBXNativeTarget section */ 133 | 97C146ED1CF9000F007C117D /* Runner */ = { 134 | isa = PBXNativeTarget; 135 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 136 | buildPhases = ( 137 | 3DDB6D1B4DF8A1DC3EDA2F0B /* [CP] Check Pods Manifest.lock */, 138 | 9740EEB61CF901F6004384FC /* Run Script */, 139 | 97C146EA1CF9000F007C117D /* Sources */, 140 | 97C146EB1CF9000F007C117D /* Frameworks */, 141 | 97C146EC1CF9000F007C117D /* Resources */, 142 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 143 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 144 | E59A9154CE587D7C5D04D92A /* [CP] Embed Pods Frameworks */, 145 | DC414BD1CFCF0DF1B9957876 /* [CP] Copy Pods Resources */, 146 | ); 147 | buildRules = ( 148 | ); 149 | dependencies = ( 150 | ); 151 | name = Runner; 152 | productName = Runner; 153 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 154 | productType = "com.apple.product-type.application"; 155 | }; 156 | /* End PBXNativeTarget section */ 157 | 158 | /* Begin PBXProject section */ 159 | 97C146E61CF9000F007C117D /* Project object */ = { 160 | isa = PBXProject; 161 | attributes = { 162 | LastUpgradeCheck = 1020; 163 | ORGANIZATIONNAME = ""; 164 | TargetAttributes = { 165 | 97C146ED1CF9000F007C117D = { 166 | CreatedOnToolsVersion = 7.3.1; 167 | LastSwiftMigration = 1100; 168 | }; 169 | }; 170 | }; 171 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 172 | compatibilityVersion = "Xcode 9.3"; 173 | developmentRegion = en; 174 | hasScannedForEncodings = 0; 175 | knownRegions = ( 176 | en, 177 | Base, 178 | ); 179 | mainGroup = 97C146E51CF9000F007C117D; 180 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 181 | projectDirPath = ""; 182 | projectRoot = ""; 183 | targets = ( 184 | 97C146ED1CF9000F007C117D /* Runner */, 185 | ); 186 | }; 187 | /* End PBXProject section */ 188 | 189 | /* Begin PBXResourcesBuildPhase section */ 190 | 97C146EC1CF9000F007C117D /* Resources */ = { 191 | isa = PBXResourcesBuildPhase; 192 | buildActionMask = 2147483647; 193 | files = ( 194 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 195 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 196 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 197 | 22C20F7826FC8F1E00C06FA8 /* testimage.jpg in Resources */, 198 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 199 | ); 200 | runOnlyForDeploymentPostprocessing = 0; 201 | }; 202 | /* End PBXResourcesBuildPhase section */ 203 | 204 | /* Begin PBXShellScriptBuildPhase section */ 205 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 206 | isa = PBXShellScriptBuildPhase; 207 | buildActionMask = 2147483647; 208 | files = ( 209 | ); 210 | inputPaths = ( 211 | ); 212 | name = "Thin Binary"; 213 | outputPaths = ( 214 | ); 215 | runOnlyForDeploymentPostprocessing = 0; 216 | shellPath = /bin/sh; 217 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 218 | }; 219 | 3DDB6D1B4DF8A1DC3EDA2F0B /* [CP] Check Pods Manifest.lock */ = { 220 | isa = PBXShellScriptBuildPhase; 221 | buildActionMask = 2147483647; 222 | files = ( 223 | ); 224 | inputFileListPaths = ( 225 | ); 226 | inputPaths = ( 227 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 228 | "${PODS_ROOT}/Manifest.lock", 229 | ); 230 | name = "[CP] Check Pods Manifest.lock"; 231 | outputFileListPaths = ( 232 | ); 233 | outputPaths = ( 234 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 235 | ); 236 | runOnlyForDeploymentPostprocessing = 0; 237 | shellPath = /bin/sh; 238 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 239 | showEnvVarsInLog = 0; 240 | }; 241 | 9740EEB61CF901F6004384FC /* Run Script */ = { 242 | isa = PBXShellScriptBuildPhase; 243 | buildActionMask = 2147483647; 244 | files = ( 245 | ); 246 | inputPaths = ( 247 | ); 248 | name = "Run Script"; 249 | outputPaths = ( 250 | ); 251 | runOnlyForDeploymentPostprocessing = 0; 252 | shellPath = /bin/sh; 253 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 254 | }; 255 | DC414BD1CFCF0DF1B9957876 /* [CP] Copy Pods Resources */ = { 256 | isa = PBXShellScriptBuildPhase; 257 | buildActionMask = 2147483647; 258 | files = ( 259 | ); 260 | inputFileListPaths = ( 261 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", 262 | ); 263 | name = "[CP] Copy Pods Resources"; 264 | outputFileListPaths = ( 265 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | shellPath = /bin/sh; 269 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; 270 | showEnvVarsInLog = 0; 271 | }; 272 | E59A9154CE587D7C5D04D92A /* [CP] Embed Pods Frameworks */ = { 273 | isa = PBXShellScriptBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | ); 277 | inputFileListPaths = ( 278 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", 279 | ); 280 | name = "[CP] Embed Pods Frameworks"; 281 | outputFileListPaths = ( 282 | "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", 283 | ); 284 | runOnlyForDeploymentPostprocessing = 0; 285 | shellPath = /bin/sh; 286 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 287 | showEnvVarsInLog = 0; 288 | }; 289 | /* End PBXShellScriptBuildPhase section */ 290 | 291 | /* Begin PBXSourcesBuildPhase section */ 292 | 97C146EA1CF9000F007C117D /* Sources */ = { 293 | isa = PBXSourcesBuildPhase; 294 | buildActionMask = 2147483647; 295 | files = ( 296 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 297 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 298 | ); 299 | runOnlyForDeploymentPostprocessing = 0; 300 | }; 301 | /* End PBXSourcesBuildPhase section */ 302 | 303 | /* Begin PBXVariantGroup section */ 304 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 305 | isa = PBXVariantGroup; 306 | children = ( 307 | 97C146FB1CF9000F007C117D /* Base */, 308 | ); 309 | name = Main.storyboard; 310 | sourceTree = ""; 311 | }; 312 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 313 | isa = PBXVariantGroup; 314 | children = ( 315 | 97C147001CF9000F007C117D /* Base */, 316 | ); 317 | name = LaunchScreen.storyboard; 318 | sourceTree = ""; 319 | }; 320 | /* End PBXVariantGroup section */ 321 | 322 | /* Begin XCBuildConfiguration section */ 323 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 324 | isa = XCBuildConfiguration; 325 | buildSettings = { 326 | ALWAYS_SEARCH_USER_PATHS = NO; 327 | CLANG_ANALYZER_NONNULL = YES; 328 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 329 | CLANG_CXX_LIBRARY = "libc++"; 330 | CLANG_ENABLE_MODULES = YES; 331 | CLANG_ENABLE_OBJC_ARC = YES; 332 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 333 | CLANG_WARN_BOOL_CONVERSION = YES; 334 | CLANG_WARN_COMMA = YES; 335 | CLANG_WARN_CONSTANT_CONVERSION = YES; 336 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 337 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 338 | CLANG_WARN_EMPTY_BODY = YES; 339 | CLANG_WARN_ENUM_CONVERSION = YES; 340 | CLANG_WARN_INFINITE_RECURSION = YES; 341 | CLANG_WARN_INT_CONVERSION = YES; 342 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 343 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 344 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 345 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 346 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 347 | CLANG_WARN_STRICT_PROTOTYPES = YES; 348 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 349 | CLANG_WARN_UNREACHABLE_CODE = YES; 350 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 351 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 352 | COPY_PHASE_STRIP = NO; 353 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 354 | ENABLE_BITCODE = NO; 355 | ENABLE_NS_ASSERTIONS = NO; 356 | ENABLE_STRICT_OBJC_MSGSEND = YES; 357 | GCC_C_LANGUAGE_STANDARD = gnu99; 358 | GCC_NO_COMMON_BLOCKS = YES; 359 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 360 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 361 | GCC_WARN_UNDECLARED_SELECTOR = YES; 362 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 363 | GCC_WARN_UNUSED_FUNCTION = YES; 364 | GCC_WARN_UNUSED_VARIABLE = YES; 365 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 366 | MTL_ENABLE_DEBUG_INFO = NO; 367 | SDKROOT = iphoneos; 368 | SUPPORTED_PLATFORMS = iphoneos; 369 | TARGETED_DEVICE_FAMILY = "1,2"; 370 | VALIDATE_PRODUCT = YES; 371 | }; 372 | name = Profile; 373 | }; 374 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 375 | isa = XCBuildConfiguration; 376 | baseConfigurationReference = 2525CED8F230DEAFBE4B49C4 /* Pods-Runner.profile.xcconfig */; 377 | buildSettings = { 378 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 379 | CLANG_ENABLE_MODULES = YES; 380 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 381 | DEVELOPMENT_TEAM = F8RNMNUKNE; 382 | ENABLE_BITCODE = NO; 383 | FLUTTER_ROOT = /Users/ara/flutter; 384 | FLUTTER_TARGET = lib/main.dart; 385 | INFOPLIST_FILE = Runner/Info.plist; 386 | LD_RUNPATH_SEARCH_PATHS = ( 387 | "$(inherited)", 388 | "@executable_path/Frameworks", 389 | ); 390 | PRODUCT_BUNDLE_IDENTIFIER = test.scan; 391 | PRODUCT_NAME = "$(TARGET_NAME)"; 392 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 393 | SWIFT_VERSION = 5.0; 394 | VERSIONING_SYSTEM = "apple-generic"; 395 | }; 396 | name = Profile; 397 | }; 398 | 97C147031CF9000F007C117D /* Debug */ = { 399 | isa = XCBuildConfiguration; 400 | buildSettings = { 401 | ALWAYS_SEARCH_USER_PATHS = NO; 402 | CLANG_ANALYZER_NONNULL = YES; 403 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 404 | CLANG_CXX_LIBRARY = "libc++"; 405 | CLANG_ENABLE_MODULES = YES; 406 | CLANG_ENABLE_OBJC_ARC = YES; 407 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 408 | CLANG_WARN_BOOL_CONVERSION = YES; 409 | CLANG_WARN_COMMA = YES; 410 | CLANG_WARN_CONSTANT_CONVERSION = YES; 411 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 412 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 413 | CLANG_WARN_EMPTY_BODY = YES; 414 | CLANG_WARN_ENUM_CONVERSION = YES; 415 | CLANG_WARN_INFINITE_RECURSION = YES; 416 | CLANG_WARN_INT_CONVERSION = YES; 417 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 418 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 419 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 420 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 421 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 422 | CLANG_WARN_STRICT_PROTOTYPES = YES; 423 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 424 | CLANG_WARN_UNREACHABLE_CODE = YES; 425 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 426 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 427 | COPY_PHASE_STRIP = NO; 428 | DEBUG_INFORMATION_FORMAT = dwarf; 429 | ENABLE_BITCODE = NO; 430 | ENABLE_STRICT_OBJC_MSGSEND = YES; 431 | ENABLE_TESTABILITY = YES; 432 | GCC_C_LANGUAGE_STANDARD = gnu99; 433 | GCC_DYNAMIC_NO_PIC = NO; 434 | GCC_NO_COMMON_BLOCKS = YES; 435 | GCC_OPTIMIZATION_LEVEL = 0; 436 | GCC_PREPROCESSOR_DEFINITIONS = ( 437 | "DEBUG=1", 438 | "$(inherited)", 439 | ); 440 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 441 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 442 | GCC_WARN_UNDECLARED_SELECTOR = YES; 443 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 444 | GCC_WARN_UNUSED_FUNCTION = YES; 445 | GCC_WARN_UNUSED_VARIABLE = YES; 446 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 447 | MTL_ENABLE_DEBUG_INFO = YES; 448 | ONLY_ACTIVE_ARCH = YES; 449 | SDKROOT = iphoneos; 450 | TARGETED_DEVICE_FAMILY = "1,2"; 451 | }; 452 | name = Debug; 453 | }; 454 | 97C147041CF9000F007C117D /* Release */ = { 455 | isa = XCBuildConfiguration; 456 | buildSettings = { 457 | ALWAYS_SEARCH_USER_PATHS = NO; 458 | CLANG_ANALYZER_NONNULL = YES; 459 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 460 | CLANG_CXX_LIBRARY = "libc++"; 461 | CLANG_ENABLE_MODULES = YES; 462 | CLANG_ENABLE_OBJC_ARC = YES; 463 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 464 | CLANG_WARN_BOOL_CONVERSION = YES; 465 | CLANG_WARN_COMMA = YES; 466 | CLANG_WARN_CONSTANT_CONVERSION = YES; 467 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 468 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 469 | CLANG_WARN_EMPTY_BODY = YES; 470 | CLANG_WARN_ENUM_CONVERSION = YES; 471 | CLANG_WARN_INFINITE_RECURSION = YES; 472 | CLANG_WARN_INT_CONVERSION = YES; 473 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 474 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 475 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 476 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 477 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 478 | CLANG_WARN_STRICT_PROTOTYPES = YES; 479 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 480 | CLANG_WARN_UNREACHABLE_CODE = YES; 481 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 482 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 483 | COPY_PHASE_STRIP = NO; 484 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 485 | ENABLE_BITCODE = NO; 486 | ENABLE_NS_ASSERTIONS = NO; 487 | ENABLE_STRICT_OBJC_MSGSEND = YES; 488 | GCC_C_LANGUAGE_STANDARD = gnu99; 489 | GCC_NO_COMMON_BLOCKS = YES; 490 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 491 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 492 | GCC_WARN_UNDECLARED_SELECTOR = YES; 493 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 494 | GCC_WARN_UNUSED_FUNCTION = YES; 495 | GCC_WARN_UNUSED_VARIABLE = YES; 496 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 497 | MTL_ENABLE_DEBUG_INFO = NO; 498 | SDKROOT = iphoneos; 499 | SUPPORTED_PLATFORMS = iphoneos; 500 | SWIFT_COMPILATION_MODE = wholemodule; 501 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 502 | TARGETED_DEVICE_FAMILY = "1,2"; 503 | VALIDATE_PRODUCT = YES; 504 | }; 505 | name = Release; 506 | }; 507 | 97C147061CF9000F007C117D /* Debug */ = { 508 | isa = XCBuildConfiguration; 509 | baseConfigurationReference = 8BC6422039662927E6BDAFEF /* Pods-Runner.debug.xcconfig */; 510 | buildSettings = { 511 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 512 | CLANG_ENABLE_MODULES = YES; 513 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 514 | DEVELOPMENT_TEAM = F8RNMNUKNE; 515 | ENABLE_BITCODE = NO; 516 | ENABLE_TESTABILITY = YES; 517 | FLUTTER_ROOT = /Users/ara/flutter; 518 | FLUTTER_TARGET = lib/main.dart; 519 | INFOPLIST_FILE = Runner/Info.plist; 520 | LD_RUNPATH_SEARCH_PATHS = ( 521 | "$(inherited)", 522 | "@executable_path/Frameworks", 523 | ); 524 | PRODUCT_BUNDLE_IDENTIFIER = test.scan; 525 | PRODUCT_NAME = "$(TARGET_NAME)"; 526 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 527 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 528 | SWIFT_VERSION = 5.0; 529 | VERSIONING_SYSTEM = "apple-generic"; 530 | }; 531 | name = Debug; 532 | }; 533 | 97C147071CF9000F007C117D /* Release */ = { 534 | isa = XCBuildConfiguration; 535 | baseConfigurationReference = E2EA15BAFF465343977BF97A /* Pods-Runner.release.xcconfig */; 536 | buildSettings = { 537 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 538 | CLANG_ENABLE_MODULES = YES; 539 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 540 | DEVELOPMENT_TEAM = F8RNMNUKNE; 541 | ENABLE_BITCODE = NO; 542 | FLUTTER_ROOT = /Users/ara/flutter; 543 | FLUTTER_TARGET = lib/main.dart; 544 | INFOPLIST_FILE = Runner/Info.plist; 545 | LD_RUNPATH_SEARCH_PATHS = ( 546 | "$(inherited)", 547 | "@executable_path/Frameworks", 548 | ); 549 | PRODUCT_BUNDLE_IDENTIFIER = test.scan; 550 | PRODUCT_NAME = "$(TARGET_NAME)"; 551 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 552 | SWIFT_VERSION = 5.0; 553 | VERSIONING_SYSTEM = "apple-generic"; 554 | }; 555 | name = Release; 556 | }; 557 | /* End XCBuildConfiguration section */ 558 | 559 | /* Begin XCConfigurationList section */ 560 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 561 | isa = XCConfigurationList; 562 | buildConfigurations = ( 563 | 97C147031CF9000F007C117D /* Debug */, 564 | 97C147041CF9000F007C117D /* Release */, 565 | 249021D3217E4FDB00AE95B9 /* Profile */, 566 | ); 567 | defaultConfigurationIsVisible = 0; 568 | defaultConfigurationName = Release; 569 | }; 570 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 571 | isa = XCConfigurationList; 572 | buildConfigurations = ( 573 | 97C147061CF9000F007C117D /* Debug */, 574 | 97C147071CF9000F007C117D /* Release */, 575 | 249021D4217E4FDB00AE95B9 /* Profile */, 576 | ); 577 | defaultConfigurationIsVisible = 0; 578 | defaultConfigurationName = Release; 579 | }; 580 | /* End XCConfigurationList section */ 581 | }; 582 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 583 | } 584 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | ScanKit 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | flutter_hms_scan_kit_example 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | NSCameraUsageDescription 28 | 请允许APP访问您的相机 29 | NSPhotoLibraryUsageDescription 30 | 请允许APP访问您的相册 31 | UILaunchStoryboardName 32 | LaunchScreen 33 | UIMainStoryboardFile 34 | Main 35 | UISupportedInterfaceOrientations 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationLandscapeLeft 39 | UIInterfaceOrientationLandscapeRight 40 | 41 | UISupportedInterfaceOrientations~ipad 42 | 43 | UIInterfaceOrientationPortrait 44 | UIInterfaceOrientationPortraitUpsideDown 45 | UIInterfaceOrientationLandscapeLeft 46 | UIInterfaceOrientationLandscapeRight 47 | 48 | UIViewControllerBasedStatusBarAppearance 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | 3 | //#import 4 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:typed_data'; 3 | 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter/services.dart'; 6 | import 'package:flutter_hms_scan_kit/flutter_hms_scan_kit.dart'; 7 | import 'package:flutter_hms_scan_kit/scan_result.dart'; 8 | 9 | void main() { 10 | runApp(MyApp()); 11 | } 12 | 13 | class MyApp extends StatefulWidget { 14 | @override 15 | _MyAppState createState() => _MyAppState(); 16 | } 17 | 18 | class _MyAppState extends State { 19 | String _platformVersion = 'Unknown'; 20 | ScanResult? _scanResult; 21 | List? _code; 22 | 23 | @override 24 | void initState() { 25 | super.initState(); 26 | initPlatformState(); 27 | generateCode(); 28 | } 29 | 30 | // Platform messages are asynchronous, so we initialize in an async method. 31 | Future initPlatformState() async { 32 | String platformVersion; 33 | // Platform messages may fail, so we use a try/catch PlatformException. 34 | // We also handle the message potentially returning null. 35 | try { 36 | platformVersion = 37 | await FlutterHmsScanKit.platformVersion ?? 'Unknown platform version'; 38 | } on PlatformException { 39 | platformVersion = 'Failed to get platform version.'; 40 | } 41 | 42 | // If the widget was removed from the tree while the asynchronous platform 43 | // message was in flight, we want to discard the reply rather than calling 44 | // setState to update our non-existent appearance. 45 | if (!mounted) return; 46 | 47 | setState(() { 48 | _platformVersion = platformVersion; 49 | }); 50 | } 51 | 52 | Future scan() async { 53 | // _scanResult = await FlutterHmsScanKit.scan; 54 | _scanResult = await FlutterHmsScanKit.startScan( 55 | isToastDebug: false, 56 | ); 57 | setState(() {}); 58 | } 59 | 60 | Future generateCode() async { 61 | var bytes = await rootBundle.load("assets/images/ic_logo.png"); 62 | _code = await FlutterHmsScanKit.generateCode( 63 | content: "这是条码", 64 | type: ScanTypeFormat.QRCODE_SCAN_TYPE, 65 | width: 300, 66 | height: 300, 67 | color: "#7CB342", 68 | logo: bytes.buffer.asUint8List(), 69 | ); 70 | setState(() {}); 71 | } 72 | 73 | @override 74 | Widget build(BuildContext context) { 75 | return MaterialApp( 76 | home: Scaffold( 77 | appBar: AppBar( 78 | title: const Text('Flutter华为扫码'), 79 | ), 80 | body: Container( 81 | width: double.infinity, 82 | padding: EdgeInsets.symmetric(vertical: 50), 83 | child: SingleChildScrollView( 84 | child: Column( 85 | children: [ 86 | Text('类型: ${_scanResult?.scanTypeForm}\n'), 87 | Text('内容类型: ${_scanResult?.scanType}\n'), 88 | Text('扫码内容: ${_scanResult?.value}\n'), 89 | ElevatedButton( 90 | onPressed: scan, 91 | child: Padding( 92 | padding: EdgeInsets.symmetric(horizontal: 100), 93 | child: Text("扫描"), 94 | ), 95 | ), 96 | SizedBox(height: 50), 97 | Text('生成条码\n'), 98 | if (_code != null) 99 | Image.memory(Uint8List.fromList(_code!)) 100 | else 101 | Container(height: 300, color: Colors.transparent), 102 | ElevatedButton( 103 | onPressed: generateCode, 104 | child: Padding( 105 | padding: EdgeInsets.symmetric(horizontal: 100), 106 | child: Text("生成条码"), 107 | ), 108 | ), 109 | ], 110 | ), 111 | ), 112 | ), 113 | ), 114 | ); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /example/pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" 9 | url: "https://pub.flutter-io.cn" 10 | source: hosted 11 | version: "2.11.0" 12 | boolean_selector: 13 | dependency: transitive 14 | description: 15 | name: boolean_selector 16 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" 17 | url: "https://pub.flutter-io.cn" 18 | source: hosted 19 | version: "2.1.1" 20 | characters: 21 | dependency: transitive 22 | description: 23 | name: characters 24 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" 25 | url: "https://pub.flutter-io.cn" 26 | source: hosted 27 | version: "1.3.0" 28 | clock: 29 | dependency: transitive 30 | description: 31 | name: clock 32 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf 33 | url: "https://pub.flutter-io.cn" 34 | source: hosted 35 | version: "1.1.1" 36 | collection: 37 | dependency: transitive 38 | description: 39 | name: collection 40 | sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" 41 | url: "https://pub.flutter-io.cn" 42 | source: hosted 43 | version: "1.17.1" 44 | cupertino_icons: 45 | dependency: "direct main" 46 | description: 47 | name: cupertino_icons 48 | sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be 49 | url: "https://pub.flutter-io.cn" 50 | source: hosted 51 | version: "1.0.5" 52 | fake_async: 53 | dependency: transitive 54 | description: 55 | name: fake_async 56 | sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" 57 | url: "https://pub.flutter-io.cn" 58 | source: hosted 59 | version: "1.3.1" 60 | flutter: 61 | dependency: "direct main" 62 | description: flutter 63 | source: sdk 64 | version: "0.0.0" 65 | flutter_hms_scan_kit: 66 | dependency: "direct main" 67 | description: 68 | path: ".." 69 | relative: true 70 | source: path 71 | version: "1.1.1" 72 | flutter_test: 73 | dependency: "direct dev" 74 | description: flutter 75 | source: sdk 76 | version: "0.0.0" 77 | flutter_web_plugins: 78 | dependency: transitive 79 | description: flutter 80 | source: sdk 81 | version: "0.0.0" 82 | fluttertoast: 83 | dependency: transitive 84 | description: 85 | name: fluttertoast 86 | sha256: "474f7d506230897a3cd28c965ec21c5328ae5605fc9c400cd330e9e9d6ac175c" 87 | url: "https://pub.flutter-io.cn" 88 | source: hosted 89 | version: "8.2.2" 90 | js: 91 | dependency: transitive 92 | description: 93 | name: js 94 | sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 95 | url: "https://pub.flutter-io.cn" 96 | source: hosted 97 | version: "0.6.7" 98 | matcher: 99 | dependency: transitive 100 | description: 101 | name: matcher 102 | sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" 103 | url: "https://pub.flutter-io.cn" 104 | source: hosted 105 | version: "0.12.15" 106 | material_color_utilities: 107 | dependency: transitive 108 | description: 109 | name: material_color_utilities 110 | sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 111 | url: "https://pub.flutter-io.cn" 112 | source: hosted 113 | version: "0.2.0" 114 | meta: 115 | dependency: transitive 116 | description: 117 | name: meta 118 | sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" 119 | url: "https://pub.flutter-io.cn" 120 | source: hosted 121 | version: "1.9.1" 122 | path: 123 | dependency: transitive 124 | description: 125 | name: path 126 | sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" 127 | url: "https://pub.flutter-io.cn" 128 | source: hosted 129 | version: "1.8.3" 130 | sky_engine: 131 | dependency: transitive 132 | description: flutter 133 | source: sdk 134 | version: "0.0.99" 135 | source_span: 136 | dependency: transitive 137 | description: 138 | name: source_span 139 | sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 140 | url: "https://pub.flutter-io.cn" 141 | source: hosted 142 | version: "1.9.1" 143 | stack_trace: 144 | dependency: transitive 145 | description: 146 | name: stack_trace 147 | sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 148 | url: "https://pub.flutter-io.cn" 149 | source: hosted 150 | version: "1.11.0" 151 | stream_channel: 152 | dependency: transitive 153 | description: 154 | name: stream_channel 155 | sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" 156 | url: "https://pub.flutter-io.cn" 157 | source: hosted 158 | version: "2.1.1" 159 | string_scanner: 160 | dependency: transitive 161 | description: 162 | name: string_scanner 163 | sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" 164 | url: "https://pub.flutter-io.cn" 165 | source: hosted 166 | version: "1.2.0" 167 | term_glyph: 168 | dependency: transitive 169 | description: 170 | name: term_glyph 171 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 172 | url: "https://pub.flutter-io.cn" 173 | source: hosted 174 | version: "1.2.1" 175 | test_api: 176 | dependency: transitive 177 | description: 178 | name: test_api 179 | sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb 180 | url: "https://pub.flutter-io.cn" 181 | source: hosted 182 | version: "0.5.1" 183 | vector_math: 184 | dependency: transitive 185 | description: 186 | name: vector_math 187 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 188 | url: "https://pub.flutter-io.cn" 189 | source: hosted 190 | version: "2.1.4" 191 | sdks: 192 | dart: ">=3.0.0-0 <4.0.0" 193 | flutter: ">=1.20.0" 194 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_hms_scan_kit_example 2 | description: Demonstrates how to use the plugin. 3 | 4 | # The following line prevents the package from being accidentally published to 5 | # pub.dev using `pub publish`. This is preferred for private packages. 6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 7 | 8 | environment: 9 | sdk: ">=2.12.0 <3.0.0" 10 | 11 | dependencies: 12 | flutter: 13 | sdk: flutter 14 | 15 | flutter_hms_scan_kit: 16 | # When depending on this package from a real application you should use: 17 | # flutter_hms_scan_kit: ^x.y.z 18 | # See https://dart.dev/tools/pub/dependencies#version-constraints 19 | # The example app is bundled with the plugin so we use a path dependency on 20 | # the parent directory to use the current plugin's version. 21 | path: ../ 22 | 23 | # The following adds the Cupertino Icons font to your application. 24 | # Use with the CupertinoIcons class for iOS style icons. 25 | cupertino_icons: ^1.0.2 26 | 27 | dev_dependencies: 28 | flutter_test: 29 | sdk: flutter 30 | 31 | # For information on the generic Dart part of this file, see the 32 | # following page: https://dart.dev/tools/pub/pubspec 33 | 34 | # The following section is specific to Flutter. 35 | flutter: 36 | 37 | # The following line ensures that the Material Icons font is 38 | # included with your application, so that you can use the icons in 39 | # the material Icons class. 40 | uses-material-design: true 41 | 42 | # To add assets to your application, add an assets section, like this: 43 | assets: 44 | - assets/images/ 45 | 46 | # An image asset can refer to one or more resolution-specific "variants", see 47 | # https://flutter.dev/assets-and-images/#resolution-aware. 48 | 49 | # For details regarding adding assets from package dependencies, see 50 | # https://flutter.dev/assets-and-images/#from-packages 51 | 52 | # To add custom fonts to your application, add a fonts section here, 53 | # in this "flutter" section. Each entry in this list should have a 54 | # "family" key with the font family name, and a "fonts" key with a 55 | # list giving the asset and other descriptors for the font. For 56 | # example: 57 | # fonts: 58 | # - family: Schyler 59 | # fonts: 60 | # - asset: fonts/Schyler-Regular.ttf 61 | # - asset: fonts/Schyler-Italic.ttf 62 | # style: italic 63 | # - family: Trajan Pro 64 | # fonts: 65 | # - asset: fonts/TrajanPro.ttf 66 | # - asset: fonts/TrajanPro_Bold.ttf 67 | # weight: 700 68 | # 69 | # For details regarding fonts from package dependencies, 70 | # see https://flutter.dev/custom-fonts/#from-packages 71 | -------------------------------------------------------------------------------- /example/test/Flutter插件发布步骤.md: -------------------------------------------------------------------------------- 1 | #一、代理和翻墙设置 2 | - 翻墙工具自己搞定 3 | - 代理设置,端口可自己设置(一定要在WIN+R CMD进去终端设置代理) 4 | - 然后打开谷歌网址测试一下[Google](https://www.google.com/) 5 | 6 | Windows 7 | ~~~ 8 | set http_proxy=127.0.0.1:7890 9 | set https_proxy=127.0.0.1:7890 10 | ~~~ 11 | Mac 12 | ~~~ 13 | export http_proxy=127.0.0.1:7890 14 | export https_proxy=127.0.0.1:7890 15 | ~~~ 16 | 测试是否翻墙 17 | ~~~ 18 | curl accounts.google.com 19 | ~~~ 20 | 返回下面代码信息就是表示成功 21 | 22 | ![](https://upload-images.jianshu.io/upload_images/4369261-e89f4ea2dfb601ea.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) 23 | 24 | #二、检查项目 25 | ~~~ 26 | flutter pub publish --dry-run 27 | ~~~ 28 | - CHANGELOG 版本记录 29 | - LINCENSE 开源文件 30 | - READNE 使用说明 31 | 32 | #三、项目配置 33 | pubspec文件 34 | ~~~ 35 | version: 版本号 36 | homepage: GitHub项目地址 37 | ~~~ 38 | 39 | #四、发布 40 | 测试是否翻墙 41 | ~~~ 42 | curl accounts.google.com 43 | ~~~ 44 | 复制下面命令直接运行 45 | ~~~ 46 | flutter packages pub publish --server=https://pub.dartlang.org 47 | ~~~ 48 | ####会有一下几个步骤 49 | 1. 检查项目 50 | 2. 询问是否发布 y就行 51 | 3. 授权:把地址复制到浏览器打开就行 52 | 4. 等待上传 53 | 5. 恭喜你,发布成功,过一会就可以在[Dart packages](https://pub.dev/) 54 | 搜索到了 55 | 56 | #五、注意 57 | - 第一点最为重要 58 | ### 问题一 59 | ~~~ 60 | It looks like accounts.google.com is having some trouble. 61 | Pub will wait for a while before trying to connect again. 62 | OS Error: Operation timed out, errno = 60, 63 | address = accounts.google.com, port = 53481 64 | pub finished with exit code 69 65 | ~~~ 66 | 原因: 67 | 1. 国内墙 68 | 2. flutter环境配置添加了国内镜像 69 | 70 | 解决方式: 71 | 1. 翻墙 72 | 2. 屏蔽环境变量里关于flutter的国内镜像 73 | 屏蔽方式如下: 74 | ~~~ 75 | export PUB_HOSTED_URL=https://pub.flutter-io.cn 76 | ~~~ 77 | ~~~ 78 | export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn 79 | ~~~ 80 | 3. 设置终端(CMD)代理命令(第一点) -------------------------------------------------------------------------------- /example/test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility that Flutter provides. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:flutter_hms_scan_kit_example/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Verify Platform version', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(MyApp()); 17 | 18 | // Verify that platform version is retrieved. 19 | expect( 20 | find.byWidgetPredicate( 21 | (Widget widget) => widget is Text && 22 | widget.data!.startsWith('Running on:'), 23 | ), 24 | findsOneWidget, 25 | ); 26 | }); 27 | } 28 | -------------------------------------------------------------------------------- /flutter_hms_scan_kit.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /image/scan_kit_example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/image/scan_kit_example.jpg -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | .generated/ 16 | 17 | *.pbxuser 18 | *.mode1v3 19 | *.mode2v3 20 | *.perspectivev3 21 | 22 | !default.pbxuser 23 | !default.mode1v3 24 | !default.mode2v3 25 | !default.perspectivev3 26 | 27 | xcuserdata 28 | 29 | *.moved-aside 30 | 31 | *.pyc 32 | *sync/ 33 | Icon? 34 | .tags* 35 | 36 | /Flutter/Generated.xcconfig 37 | /Flutter/ephemeral/ 38 | /Flutter/flutter_export_environment.sh -------------------------------------------------------------------------------- /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1244752609/flutter_hms_scan_kit/d4ad27bcda6eb30f960c0189c5eb92db9b11bae3/ios/Assets/.gitkeep -------------------------------------------------------------------------------- /ios/Classes/FlutterHmsScanKitPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface FlutterHmsScanKitPlugin : NSObject 4 | @end 5 | -------------------------------------------------------------------------------- /ios/Classes/FlutterHmsScanKitPlugin.m: -------------------------------------------------------------------------------- 1 | #import "FlutterHmsScanKitPlugin.h" 2 | #if __has_include() 3 | #import 4 | #else 5 | // Support project import fallback if the generated compatibility header 6 | // is not copied when this plugin is created as a library. 7 | // https://forums.swift.org/t/swift-static-libraries-dont-copy-generated-objective-c-header/19816 8 | #import "flutter_hms_scan_kit-Swift.h" 9 | #endif 10 | 11 | @implementation FlutterHmsScanKitPlugin 12 | + (void)registerWithRegistrar:(NSObject*)registrar { 13 | [SwiftFlutterHmsScanKitPlugin registerWithRegistrar:registrar]; 14 | } 15 | @end 16 | -------------------------------------------------------------------------------- /ios/Classes/SwiftFlutterHmsScanKitPlugin.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import ScanKitFrameWork 4 | 5 | public class SwiftFlutterHmsScanKitPlugin: NSObject, FlutterPlugin, DefaultScanDelegate { 6 | private var hostViewController: UIViewController? 7 | private var result: FlutterResult? 8 | 9 | public static func register(with registrar: FlutterPluginRegistrar) { 10 | let channel = FlutterMethodChannel(name: "Aar/FlutterHmsScanKit", binaryMessenger: registrar.messenger()) 11 | let instance = SwiftFlutterHmsScanKitPlugin() 12 | 13 | instance.hostViewController = UIApplication.shared.delegate?.window??.rootViewController 14 | 15 | registrar.addMethodCallDelegate(instance, channel: channel) 16 | } 17 | 18 | public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { 19 | self.result = result 20 | if call.method == "getPlatformVersion" { 21 | result("iOS " + UIDevice.current.systemVersion) 22 | } else if call.method == "startScan" {//扫码 23 | scan(result: result) 24 | } else if call.method == "generateCode" {//生产条码 25 | let arguments = call.arguments as? [String: Any] ?? [String: Any]() 26 | let content: String? = arguments["content"] as? String ?? "not value" 27 | let type: Int? = arguments["type"] as? Int ?? 12 28 | let width: Int? = arguments["width"] as? Int 29 | let height: Int? = arguments["height"] as? Int 30 | let color: String? = arguments["color"] as? String 31 | let logo: [UInt8]? = arguments["logo"] as? [UInt8] 32 | 33 | generateCode(result: result, content: content, typeCode: type, width: width, height: height, color: color, logo: logo) 34 | } 35 | } 36 | 37 | //扫码 38 | private func scan(result: @escaping FlutterResult) { 39 | let options = HmsScanOptions(scanFormatType: UInt32(HMSScanFormatTypeCode.ALL.rawValue), photo: true) 40 | 41 | let hmsDefaultScanViewController = HmsDefaultScanViewController(defaultScanWithFormatType: options) 42 | 43 | if hmsDefaultScanViewController != nil { 44 | hmsDefaultScanViewController!.defaultScanDelegate = self 45 | hostViewController?.view.addSubview(hmsDefaultScanViewController!.view) 46 | hostViewController?.addChild(hmsDefaultScanViewController!) 47 | hostViewController?.didMove(toParent: hmsDefaultScanViewController) 48 | } 49 | } 50 | 51 | //生成条码 52 | private func generateCode(result: @escaping FlutterResult, content: String?, typeCode: Int?, width: Int?, height: Int?, color: String?, logo: [UInt8]?) { 53 | let size: CGSize = CGSize(width: width ?? 500, height: height ?? 500) 54 | var codeFormat: HMSScanFormatTypeCode 55 | switch typeCode { 56 | case 1: 57 | codeFormat = HMSScanFormatTypeCode.AZTEC 58 | case 2: 59 | codeFormat = HMSScanFormatTypeCode.DATA_MATRIX 60 | case 3: 61 | codeFormat = HMSScanFormatTypeCode.PDF_417 62 | case 4: 63 | codeFormat = HMSScanFormatTypeCode.CODE_39 64 | case 5: 65 | codeFormat = HMSScanFormatTypeCode.CODE_93 66 | case 6: 67 | codeFormat = HMSScanFormatTypeCode.CODE_128 68 | case 7: 69 | codeFormat = HMSScanFormatTypeCode.EAN_13 70 | case 8: 71 | codeFormat = HMSScanFormatTypeCode.EAN_8 72 | case 9: 73 | codeFormat = HMSScanFormatTypeCode.ITF 74 | case 10: 75 | codeFormat = HMSScanFormatTypeCode.UPC_A 76 | case 11: 77 | codeFormat = HMSScanFormatTypeCode.UPC_E 78 | case 12: 79 | codeFormat = HMSScanFormatTypeCode.CODABAR 80 | default: 81 | codeFormat = HMSScanFormatTypeCode.QR_CODE 82 | } 83 | 84 | do { 85 | let image: UIImage = try HmsMultiFormatWriter.createCode(with: content ?? "not value", size: size, codeFomart: codeFormat) 86 | let data = image.jpegData(compressionQuality: 1.0) 87 | if data != nil { 88 | let count = data?.count ?? 0 89 | var bytes: [UInt8] = [UInt8](repeating: 0, count: count) 90 | data?.copyBytes(to: &bytes, from: Range(NSRange(location: 0, length: count))!) 91 | 92 | result(["code": bytes]) 93 | } else { 94 | print("image.jpegData is null") 95 | } 96 | } catch { 97 | print(error) 98 | } 99 | } 100 | 101 | public func defaultScanDelegate(forDicResult resultDic: [AnyHashable: Any]!) { 102 | DispatchQueue.main.async { 103 | let formatValue: String = String(describing: resultDic!["formatValue"]!) 104 | print("formatValue: \(resultDic?["formatValue"] ?? "")") 105 | print("formatValue: \(formatValue)") 106 | print("formatValue: \(self.getScanType(formatValue: formatValue))") 107 | print("text: \(String(describing: resultDic["text"]))") 108 | let parserDic: [String: String]? = resultDic["parserDic"] as? [String: String] 109 | print("sceneType: \(parserDic?["sceneType"] ?? "")") 110 | print("sceneType: \(self.getScanTypeFormat(formatValue: parserDic?["sceneType"]! ?? ""))") 111 | let bytes: [String]? = resultDic["rawBytes"] as? [String] 112 | print("rawBytes: \(bytes ?? [String]())") 113 | 114 | self.result?([ 115 | "scanTypeForm": self.getScanType(formatValue: formatValue), 116 | "value": resultDic!["text"], 117 | "scanType": self.getScanTypeFormat(formatValue: parserDic?["sceneType"] ?? ""), 118 | ]) 119 | } 120 | } 121 | 122 | public func defaultScanImagePickerDelegate(for image: UIImage!) { 123 | let options = HmsScanOptions(scanFormatType: UInt32(HMSScanFormatTypeCode.ALL.rawValue), photo: true) 124 | let resultDic: [AnyHashable: Any]? = HmsBitMap.bitMap(for: image, with: options) 125 | 126 | DispatchQueue.main.async { 127 | if resultDic != nil { 128 | let formatValue: String = String(describing: resultDic!["formatValue"]!) 129 | print("formatValue: \(resultDic!["formatValue"]!)") 130 | print("formatValue: \(self.getScanType(formatValue:formatValue))") 131 | print("text: \(String(describing: resultDic!["text"]))") 132 | let parserDic: [String: String]? = resultDic!["parserDic"] as? [String: String] 133 | print("sceneType: \(parserDic?["sceneType"] ?? "")") 134 | print("sceneType: \(self.getScanTypeFormat(formatValue: parserDic?["sceneType"] ?? ""))") 135 | let bytes: [String]? = resultDic!["rawBytes"] as? [String] 136 | print("rawBytes: \(bytes ?? [String]())") 137 | 138 | self.result?([ 139 | "scanTypeForm": self.getScanType(formatValue: formatValue), 140 | "value": resultDic!["text"], 141 | "scanType": self.getScanTypeFormat(formatValue: parserDic?["sceneType"] ?? ""), 142 | ]) 143 | } 144 | } 145 | } 146 | 147 | //获取扫码类型编码 148 | func getScanType(formatValue: String?) -> Int { 149 | switch formatValue { 150 | case "QR_CODE": 151 | return 1 152 | case "AZTEC": 153 | return 2 154 | case "DATA_MATRIX": 155 | return 4 156 | case "PDF_417": 157 | return 8 158 | case "CODE_39": 159 | return 16 160 | case "CODE_93": 161 | return 32 162 | case "CODE_128": 163 | return 64 164 | case "EAN_13": 165 | return 128 166 | case "EAN_8": 167 | return 256 168 | case "ITF": 169 | return 512 170 | case "UPC_A": 171 | return 1024 172 | case "UPC_E": 173 | return 2048 174 | case "CODABAR": 175 | return 4096 176 | default: 177 | return 0 178 | } 179 | } 180 | 181 | //获取扫码类型编码 182 | func getScanTypeFormat(formatValue: String) -> Int { 183 | switch formatValue.uppercased() { 184 | case "NUMBER": 185 | return 1001 186 | case "EMAIL": 187 | return 1002 188 | case "TEL": 189 | return 1003 190 | case "TEXT": 191 | return 1004 192 | case "SMS": 193 | return 1005 194 | case "WEBSITE"://url 195 | return 1006 196 | case "WI-FI": 197 | return 1007 198 | case "EVENT": 199 | return 1008 200 | case "CONTACT": 201 | return 1009 202 | case "DRIVER": 203 | return 10010 204 | case "LOCATION": 205 | return 10011 206 | case "BOOK": 207 | return 10012 208 | case "VEHICLE": 209 | return 10013 210 | case "PURE_TEXT": 211 | return 10014 212 | default: 213 | return 0 214 | } 215 | } 216 | 217 | } 218 | -------------------------------------------------------------------------------- /ios/flutter_hms_scan_kit.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. 3 | # Run `pod lib lint flutter_hms_scan_kit.podspec` to validate before publishing. 4 | # 5 | Pod::Spec.new do |s| 6 | s.name = 'flutter_hms_scan_kit' 7 | s.version = '1.1.4' #升级需要变动 8 | s.summary = '华为统一扫码服务' 9 | s.description = <<-DESC 10 | 华为统一扫码服务 11 | DESC 12 | s.homepage = 'https://github.com/1244752609/flutter_hms_scan_kit' 13 | s.license = { :file => '../LICENSE' } 14 | s.author = { 'xiexin' => 'xiexin.xie@qq.com' } 15 | s.source = { :path => '.' } 16 | s.source_files = 'Classes/**/*' 17 | s.dependency 'Flutter' 18 | # 第一次更新使用pod install ,已经更新过使用pod update 19 | s.dependency 'ScanKitFrameWork', '~> 1.1.0.306' 20 | s.platform = :ios, '11.0' 21 | 22 | # Flutter.framework does not contain a i386 slice. 23 | s.pod_target_xcconfig = { 'ENABLE_BITCODE' => 'NO', 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } 24 | s.swift_version = '5.0' 25 | 26 | # ScanKitFrameWork.framework 华为统一扫码服务 27 | # s.ios.vendored_frameworks = 'ScanKitFrameWork.framework' 28 | # s.vendored_frameworks = 'ScanKitFrameWork.framework' 29 | end 30 | -------------------------------------------------------------------------------- /lib/flutter_hms_scan_kit.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/services.dart'; 4 | import 'package:flutter_hms_scan_kit/scan_result.dart'; 5 | import 'package:flutter_hms_scan_kit/toast_utils.dart'; 6 | 7 | class FlutterHmsScanKit { 8 | static MethodChannel _channel = MethodChannel('Aar/FlutterHmsScanKit'); 9 | static bool isClick = false; 10 | 11 | static Future get platformVersion async { 12 | final String? version = await _channel.invokeMethod('getPlatformVersion'); 13 | return version; 14 | } 15 | 16 | ///扫码 17 | static Future get scan async { 18 | return startScan(); 19 | } 20 | 21 | /// 扫码 22 | /// isContinuousClick 是否连续点击 true-是 23 | /// isToastDebug 是否toast 用于测试 true-是 24 | static Future startScan({ 25 | bool isContinuousClick = true, 26 | bool isToastDebug = false, 27 | }) async { 28 | if (isContinuousClick) { 29 | if (isClick) return null; 30 | isClick = true; 31 | Future.delayed(Duration(milliseconds: 500), () => isClick = false); 32 | } 33 | if (isToastDebug) ToastUtils.showLong("调起原生扫码"); 34 | Map map = {"isToast": isToastDebug}; 35 | try { 36 | var result = await _channel.invokeMethod('startScan', map) as Map; 37 | final scanType = result['scanType'] as int; 38 | final scanTypeForm = result['scanTypeForm'] as int; 39 | final value = result['value'] != null ? result['value'] as String : null; 40 | final valueByte = 41 | result['valueByte'] != null ? result['valueByte'] as List : null; 42 | print("========> scanType: $scanType"); 43 | print("========> scanTypeForm: $scanTypeForm"); 44 | print("========> value: $value"); 45 | print("========> valueByte: $valueByte"); 46 | ScanResult scanResult = ScanResult(); 47 | scanResult.scanType = getScanType(scanType); 48 | scanResult.scanTypeForm = getScanTypeFormat(scanTypeForm); 49 | scanResult.value = value; 50 | scanResult.valueByte = valueByte; 51 | if (isToastDebug) ToastUtils.showLong("扫码成功:$value"); 52 | return scanResult; 53 | } catch (e) { 54 | print(e); 55 | ToastUtils.showLong("调起扫码失败:$e"); 56 | return null; 57 | } 58 | } 59 | 60 | ///生产条码 61 | static Future?> generateCode({ 62 | String content = "", //内容 63 | ScanTypeFormat type = ScanTypeFormat.QRCODE_SCAN_TYPE, //码类型 ScanType 64 | int width = 500, //宽 65 | int height = 500, //高 66 | String color = "#000000", //码颜色 67 | Uint8List? logo, //logo 68 | bool isToastDebug = false, 69 | }) async { 70 | if (logo == null) logo = Uint8List.fromList([]); 71 | Map map = { 72 | "content": content, 73 | "type": scanType(type), 74 | "width": width, 75 | "height": height, 76 | "color": color, 77 | "logo": logo, 78 | }; 79 | if (isToastDebug) ToastUtils.showLong("调起原生生产条码"); 80 | var result = await _channel.invokeMethod('generateCode', map) as Map; 81 | final code = result['code'] as List; 82 | final List list = code.map((item) { 83 | return int.parse(item!.toString()); 84 | }).toList(); 85 | if (isToastDebug) ToastUtils.showLong("生产条码成功"); 86 | return list; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /lib/scan_result.dart: -------------------------------------------------------------------------------- 1 | class ScanResult { 2 | /// 扫码结果信息 3 | ScanType? scanType; 4 | 5 | /// 条码内容类型 6 | ScanTypeFormat? scanTypeForm; 7 | 8 | /// 获取条码原始的全部码值信息。只有当条码编码格式为UTF-8时才可以使用 9 | String? value; 10 | 11 | /// 非UTF-8格式的条码使用 12 | List? valueByte; 13 | } 14 | 15 | ScanTypeFormat getScanTypeFormat(int type) { 16 | switch (type) { 17 | case 1: 18 | return ScanTypeFormat.QRCODE_SCAN_TYPE; 19 | case 2: 20 | return ScanTypeFormat.AZTEC_SCAN_TYPE; 21 | case 4: 22 | return ScanTypeFormat.DATAMATRIX_SCAN_TYPE; 23 | case 8: 24 | return ScanTypeFormat.PDF417_SCAN_TYPE; 25 | case 16: 26 | return ScanTypeFormat.CODE39_SCAN_TYPE; 27 | case 32: 28 | return ScanTypeFormat.CODE93_SCAN_TYPE; 29 | case 64: 30 | return ScanTypeFormat.CODE128_SCAN_TYPE; 31 | case 128: 32 | return ScanTypeFormat.EAN13_SCAN_TYPE; 33 | case 256: 34 | return ScanTypeFormat.EAN8_SCAN_TYPE; 35 | case 512: 36 | return ScanTypeFormat.ITF14_SCAN_TYPE; 37 | case 1024: 38 | return ScanTypeFormat.UPCCODE_A_SCAN_TYPE; 39 | case 2048: 40 | return ScanTypeFormat.UPCCODE_E_SCAN_TYPE; 41 | case 4096: 42 | return ScanTypeFormat.CODABAR_SCAN_TYPE; 43 | default: 44 | return ScanTypeFormat.FORMAT_UNKNOWN; 45 | } 46 | } 47 | 48 | int scanType(ScanTypeFormat type) { 49 | switch (type) { 50 | case ScanTypeFormat.QRCODE_SCAN_TYPE: 51 | return 0; 52 | case ScanTypeFormat.AZTEC_SCAN_TYPE: 53 | return 1; 54 | case ScanTypeFormat.DATAMATRIX_SCAN_TYPE: 55 | return 2; 56 | case ScanTypeFormat.PDF417_SCAN_TYPE: 57 | return 3; 58 | case ScanTypeFormat.CODE39_SCAN_TYPE: 59 | return 4; 60 | case ScanTypeFormat.CODE93_SCAN_TYPE: 61 | return 5; 62 | case ScanTypeFormat.CODE128_SCAN_TYPE: 63 | return 6; 64 | case ScanTypeFormat.EAN13_SCAN_TYPE: 65 | return 7; 66 | case ScanTypeFormat.EAN8_SCAN_TYPE: 67 | return 8; 68 | case ScanTypeFormat.ITF14_SCAN_TYPE: 69 | return 9; 70 | case ScanTypeFormat.UPCCODE_A_SCAN_TYPE: 71 | return 10; 72 | case ScanTypeFormat.UPCCODE_E_SCAN_TYPE: 73 | return 11; 74 | case ScanTypeFormat.CODABAR_SCAN_TYPE: 75 | return 12; 76 | default: 77 | return 0; 78 | } 79 | } 80 | 81 | ///扫码结果信息 82 | enum ScanTypeFormat { 83 | ///无法识别扫描条码类型。 84 | FORMAT_UNKNOWN, //-1 85 | ///扫码类型设置-扫描所有条码类型。 86 | ALL_SCAN_TYPE, //0 87 | ///QR Code条码类型。 88 | QRCODE_SCAN_TYPE, //1 89 | ///Aztec条码类型。 90 | AZTEC_SCAN_TYPE, //2 91 | ///Data Matrix条码类型。 92 | DATAMATRIX_SCAN_TYPE, //4 93 | ///PDF417条码类型。 94 | PDF417_SCAN_TYPE, //8 95 | ///Code 39条码类型。 96 | CODE39_SCAN_TYPE, //16 97 | ///Code 93条码类型。 98 | CODE93_SCAN_TYPE, //32 99 | ///Code 128条码类型。 100 | CODE128_SCAN_TYPE, //64 101 | ///EAN-13条码类型。 102 | EAN13_SCAN_TYPE, //128 103 | ///EAN-8条码类型。 104 | EAN8_SCAN_TYPE, //256 105 | ///ITF-14条码类型。 106 | ITF14_SCAN_TYPE, //512 107 | ///UPC-A条码类型。 108 | UPCCODE_A_SCAN_TYPE, //1024 109 | ///UPC-E条码类型。 110 | UPCCODE_E_SCAN_TYPE, //2048 111 | ///Codabar条码类型。 112 | CODABAR_SCAN_TYPE, //4096 113 | } 114 | 115 | ScanType getScanType(int type) { 116 | switch (type) { 117 | case 1001: 118 | return ScanType.ARTICLE_NUMBER_FORM; 119 | case 1002: 120 | return ScanType.EMAIL_CONTENT_FORM; 121 | case 1003: 122 | return ScanType.TEL_PHONE_NUMBER_FORM; 123 | case 1004: 124 | return ScanType.PURE_TEXT_FORM; 125 | case 1005: 126 | return ScanType.SMS_FORM; 127 | case 1006: 128 | return ScanType.URL_FORM; 129 | case 1007: 130 | return ScanType.WIFI_CONNECT_INFO_FORM; 131 | case 1008: 132 | return ScanType.EVENT_INFO_FORM; 133 | case 1009: 134 | return ScanType.CONTACT_DETAIL_FORM; 135 | case 10010: 136 | return ScanType.DRIVER_INFO_FORM; 137 | case 10011: 138 | return ScanType.LOCATION_COORDINATE_FORM; 139 | case 10012: 140 | return ScanType.ISBN_NUMBER_FORM; 141 | case 10013: 142 | return ScanType.BOOK_MARK_FORM; 143 | case 10014: 144 | return ScanType.VEHICLE_INFO_FORM; 145 | default: 146 | return ScanType.PURE_TEXT_FORM; 147 | } 148 | } 149 | 150 | ///条码内容类型 151 | enum ScanType { 152 | ///商品条码 153 | ARTICLE_NUMBER_FORM, //1001 154 | ///邮件 155 | EMAIL_CONTENT_FORM, //1002 156 | ///电话 157 | TEL_PHONE_NUMBER_FORM, //1003 158 | ///文本 159 | PURE_TEXT_FORM, //1004 160 | ///短信 161 | SMS_FORM, //1005 162 | ///网页 163 | URL_FORM, //1006 164 | ///Wi-Fi连接信息 165 | WIFI_CONNECT_INFO_FORM, //1007 166 | ///事件 167 | EVENT_INFO_FORM, //1008 168 | ///联系人信息 169 | CONTACT_DETAIL_FORM, //1009 170 | ///设备信息 171 | DRIVER_INFO_FORM, //10010 172 | ///地理位置 173 | LOCATION_COORDINATE_FORM, //10011 174 | ///ISBN 175 | ISBN_NUMBER_FORM, //10012 176 | ///书签 177 | BOOK_MARK_FORM, //10013 178 | ///车辆信息 179 | VEHICLE_INFO_FORM, //10014 180 | } 181 | -------------------------------------------------------------------------------- /lib/toast_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:fluttertoast/fluttertoast.dart'; 3 | 4 | /// Created by XieXin on 2020/4/8. 5 | /// Toast工具类 6 | class ToastUtils { 7 | ///短Toast 8 | static Future showShort( 9 | String msg, { 10 | ToastGravity gravity = ToastGravity.CENTER, 11 | Color? backgroundColor, 12 | Color textColor = Colors.white, 13 | double fontSize = 12.0, 14 | }) { 15 | return Fluttertoast.showToast( 16 | msg: msg, 17 | toastLength: Toast.LENGTH_SHORT, 18 | gravity: gravity, 19 | backgroundColor: backgroundColor ?? Color.fromRGBO(0, 0, 0, 0.6), 20 | textColor: Colors.white, 21 | fontSize: fontSize, 22 | ); 23 | } 24 | 25 | ///长Toast 26 | static Future showLong( 27 | String msg, { 28 | ToastGravity gravity = ToastGravity.CENTER, 29 | Color? backgroundColor, 30 | Color textColor = Colors.white, 31 | double fontSize = 12.0, 32 | }) { 33 | return Fluttertoast.showToast( 34 | msg: msg, 35 | toastLength: Toast.LENGTH_LONG, 36 | gravity: gravity, 37 | backgroundColor: backgroundColor ?? Color.fromRGBO(0, 0, 0, 0.6), 38 | textColor: Colors.white, 39 | fontSize: fontSize, 40 | ); 41 | } 42 | 43 | ///自定义Toast 44 | static Future showToast( 45 | String msg, { 46 | Toast toastLength = Toast.LENGTH_SHORT, 47 | int timeInSecForIosWeb = 1, 48 | ToastGravity gravity = ToastGravity.CENTER, 49 | Color? backgroundColor, 50 | Color textColor = Colors.white, 51 | double fontSize = 12.0, 52 | }) { 53 | return Fluttertoast.showToast( 54 | msg: msg, 55 | toastLength: toastLength, 56 | timeInSecForIosWeb: timeInSecForIosWeb, 57 | gravity: gravity, 58 | backgroundColor: backgroundColor ?? Color.fromRGBO(0, 0, 0, 0.6), 59 | textColor: Colors.white, 60 | fontSize: fontSize, 61 | ); 62 | } 63 | 64 | ///取消全部Toast 65 | static Future cancel() { 66 | return Fluttertoast.cancel(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" 9 | url: "https://pub.flutter-io.cn" 10 | source: hosted 11 | version: "2.11.0" 12 | boolean_selector: 13 | dependency: transitive 14 | description: 15 | name: boolean_selector 16 | sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" 17 | url: "https://pub.flutter-io.cn" 18 | source: hosted 19 | version: "2.1.1" 20 | characters: 21 | dependency: transitive 22 | description: 23 | name: characters 24 | sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" 25 | url: "https://pub.flutter-io.cn" 26 | source: hosted 27 | version: "1.3.0" 28 | clock: 29 | dependency: transitive 30 | description: 31 | name: clock 32 | sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf 33 | url: "https://pub.flutter-io.cn" 34 | source: hosted 35 | version: "1.1.1" 36 | collection: 37 | dependency: transitive 38 | description: 39 | name: collection 40 | sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c" 41 | url: "https://pub.flutter-io.cn" 42 | source: hosted 43 | version: "1.17.1" 44 | fake_async: 45 | dependency: transitive 46 | description: 47 | name: fake_async 48 | sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" 49 | url: "https://pub.flutter-io.cn" 50 | source: hosted 51 | version: "1.3.1" 52 | flutter: 53 | dependency: "direct main" 54 | description: flutter 55 | source: sdk 56 | version: "0.0.0" 57 | flutter_test: 58 | dependency: "direct dev" 59 | description: flutter 60 | source: sdk 61 | version: "0.0.0" 62 | flutter_web_plugins: 63 | dependency: transitive 64 | description: flutter 65 | source: sdk 66 | version: "0.0.0" 67 | fluttertoast: 68 | dependency: "direct main" 69 | description: 70 | name: fluttertoast 71 | sha256: "474f7d506230897a3cd28c965ec21c5328ae5605fc9c400cd330e9e9d6ac175c" 72 | url: "https://pub.flutter-io.cn" 73 | source: hosted 74 | version: "8.2.2" 75 | js: 76 | dependency: transitive 77 | description: 78 | name: js 79 | sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 80 | url: "https://pub.flutter-io.cn" 81 | source: hosted 82 | version: "0.6.7" 83 | matcher: 84 | dependency: transitive 85 | description: 86 | name: matcher 87 | sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb" 88 | url: "https://pub.flutter-io.cn" 89 | source: hosted 90 | version: "0.12.15" 91 | material_color_utilities: 92 | dependency: transitive 93 | description: 94 | name: material_color_utilities 95 | sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 96 | url: "https://pub.flutter-io.cn" 97 | source: hosted 98 | version: "0.2.0" 99 | meta: 100 | dependency: transitive 101 | description: 102 | name: meta 103 | sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" 104 | url: "https://pub.flutter-io.cn" 105 | source: hosted 106 | version: "1.9.1" 107 | path: 108 | dependency: transitive 109 | description: 110 | name: path 111 | sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" 112 | url: "https://pub.flutter-io.cn" 113 | source: hosted 114 | version: "1.8.3" 115 | sky_engine: 116 | dependency: transitive 117 | description: flutter 118 | source: sdk 119 | version: "0.0.99" 120 | source_span: 121 | dependency: transitive 122 | description: 123 | name: source_span 124 | sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 125 | url: "https://pub.flutter-io.cn" 126 | source: hosted 127 | version: "1.9.1" 128 | stack_trace: 129 | dependency: transitive 130 | description: 131 | name: stack_trace 132 | sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 133 | url: "https://pub.flutter-io.cn" 134 | source: hosted 135 | version: "1.11.0" 136 | stream_channel: 137 | dependency: transitive 138 | description: 139 | name: stream_channel 140 | sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" 141 | url: "https://pub.flutter-io.cn" 142 | source: hosted 143 | version: "2.1.1" 144 | string_scanner: 145 | dependency: transitive 146 | description: 147 | name: string_scanner 148 | sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" 149 | url: "https://pub.flutter-io.cn" 150 | source: hosted 151 | version: "1.2.0" 152 | term_glyph: 153 | dependency: transitive 154 | description: 155 | name: term_glyph 156 | sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 157 | url: "https://pub.flutter-io.cn" 158 | source: hosted 159 | version: "1.2.1" 160 | test_api: 161 | dependency: transitive 162 | description: 163 | name: test_api 164 | sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb 165 | url: "https://pub.flutter-io.cn" 166 | source: hosted 167 | version: "0.5.1" 168 | vector_math: 169 | dependency: transitive 170 | description: 171 | name: vector_math 172 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 173 | url: "https://pub.flutter-io.cn" 174 | source: hosted 175 | version: "2.1.4" 176 | sdks: 177 | dart: ">=3.0.0-0 <4.0.0" 178 | flutter: ">=1.20.0" 179 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_hms_scan_kit 2 | description: 华为统一扫码服务 3 | version: 1.1.4 4 | homepage: https://github.com/1244752609/flutter_hms_scan_kit 5 | 6 | environment: 7 | sdk: ">=2.12.0 <3.0.0" 8 | flutter: ">=1.20.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | # Toast https://pub.dev/packages/fluttertoast 14 | fluttertoast: ^8.2.1 15 | 16 | dev_dependencies: 17 | flutter_test: 18 | sdk: flutter 19 | 20 | # For information on the generic Dart part of this file, see the 21 | # following page: https://dart.dev/tools/pub/pubspec 22 | 23 | # The following section is specific to Flutter. 24 | flutter: 25 | # This section identifies this Flutter project as a plugin project. 26 | # The 'pluginClass' and Android 'package' identifiers should not ordinarily 27 | # be modified. They are used by the tooling to maintain consistency when 28 | # adding or updating assets for this project. 29 | plugin: 30 | platforms: 31 | android: 32 | package: com.ara.flutter_hms_scan_kit 33 | pluginClass: FlutterHmsScanKitPlugin 34 | ios: 35 | pluginClass: FlutterHmsScanKitPlugin 36 | 37 | # To add assets to your plugin package, add an assets section, like this: 38 | # assets: 39 | # - images/a_dot_burr.jpeg 40 | # - images/a_dot_ham.jpeg 41 | # 42 | # For details regarding assets in packages, see 43 | # https://flutter.dev/assets-and-images/#from-packages 44 | # 45 | # An image asset can refer to one or more resolution-specific "variants", see 46 | # https://flutter.dev/assets-and-images/#resolution-aware. 47 | 48 | # To add custom fonts to your plugin package, add a fonts section here, 49 | # in this "flutter" section. Each entry in this list should have a 50 | # "family" key with the font family name, and a "fonts" key with a 51 | # list giving the asset and other descriptors for the font. For 52 | # example: 53 | # fonts: 54 | # - family: Schyler 55 | # fonts: 56 | # - asset: fonts/Schyler-Regular.ttf 57 | # - asset: fonts/Schyler-Italic.ttf 58 | # style: italic 59 | # - family: Trajan Pro 60 | # fonts: 61 | # - asset: fonts/TrajanPro.ttf 62 | # - asset: fonts/TrajanPro_Bold.ttf 63 | # weight: 700 64 | # 65 | # For details regarding fonts in packages, see 66 | # https://flutter.dev/custom-fonts/#from-packages 67 | -------------------------------------------------------------------------------- /test/flutter_hms_scan_kit_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/services.dart'; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | import 'package:flutter_hms_scan_kit/flutter_hms_scan_kit.dart'; 4 | 5 | void main() { 6 | const MethodChannel channel = MethodChannel('flutter_hms_scan_kit'); 7 | 8 | TestWidgetsFlutterBinding.ensureInitialized(); 9 | 10 | setUp(() { 11 | channel.setMockMethodCallHandler((MethodCall methodCall) async { 12 | return '42'; 13 | }); 14 | }); 15 | 16 | tearDown(() { 17 | channel.setMockMethodCallHandler(null); 18 | }); 19 | 20 | test('getPlatformVersion', () async { 21 | expect(await FlutterHmsScanKit.platformVersion, '42'); 22 | }); 23 | } 24 | --------------------------------------------------------------------------------