flutter_scanner 0.1.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 74

flutter_scanner #

totem

flutter_scanner:支持Android和IOS识别'一维条码'和'二维条码'的识别

pub package

亮点: flutter_scanner:支持在flutter页面中嵌入Scanner以此来应对多变的业务需求

效果效果

flutter_scanner项目中的实战应用flutter sample

下载安卓apk安装包IOS安装包,请下载example后运行项目获取博客地址

1.安装 #

使用当前包作为依赖库

1. 依赖此库 #

在文件 'pubspec.yaml' 中添加

pub package


dependencies:

  flutter_scanner: ^version

或者以下方式依赖

dependencies:

  # Scanner package.
  flutter_scanner:
    git:
      url: https://github.com/pdliuw/flutter_scanner.git

2. 安装此库 #

你可以通过下面的命令行来安装此库


$ flutter pub get


你也可以通过项目开发工具通过可视化操作来执行上述步骤

3. 导入此库 #

现在,在你的Dart编辑代码中,你可以使用:


import 'package:flutter_scanner/flutter_scanner.dart';

2.使用 #

使用'相机'需要动态申请权限,动态权限推荐:permission_handler

1.使用'一维条码、二维条码'的地方中: #

简要示例

                //cameraWidth:相机的宽度;cameraHeight相机的高度,可根据实际的业务来动态调整
                Container(
                  color: Colors.black26,
                  width: cameraWidth,
                  height: cameraHeight,
                  child: PlatformScannerWidget(
                    platformScannerController: _scannerController,
                  ),
                ),

完整示例

完整示例,点击这里

2.调用/应用 #

*1、打开相机设备


          _scannerController.startCamera();

*2、打开预览/识别'条码'


          _scannerController.startCameraPreview();

*3、关闭预览/识别'条码'


      _scannerController.stopCameraPreview();

*4、关闭相机设备


      _scannerController.stopCamera();

*5、打开手电筒


      _scannerController.openFlash();

*5、关闭手电筒


      _scannerController.closeFlash();

*5、切换手电筒


      _scannerController.toggleFlash();

看到这里还意犹未尽?点击,查看项目示例

LICENSE #

Copyright 2019 pdliuw

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

[0.0.1] #

  • Initial release.

[0.1.1] #

  • barcode scanner supported!

[0.1.2] #

  • Fix:something.

[0.1.3] #

  • Fix:something.

[0.1.4] #

  • Fix:something.

[0.1.5] #

  • Fix:something.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:airoute/airoute.dart';
import 'package:flutter_scanner_example/task_next_page.dart';
import 'package:flutter_scanner_example/task_scanner_page.dart';

void main() => runApp(
      Airoute.createMaterialApp(
        home: App(),
        routes: <String, AirouteBuilder>{
          "/TaskScannerPage": () => TaskScannerPage(),
          "/TaskNextPage": () => TaskNextPage(),
        },
      ),
    );

///
/// App
class App extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _AppState();
  }
}

///
/// _AppState
class _AppState extends State<App> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("条码扫描"),
      ),
      body: Center(
        child: MaterialButton(
          onPressed: () {
            /*
              跳转页面
               */
            Airoute.pushNamed(
              routeName: "/TaskScannerPage",
            );
          },
          textColor: Colors.white,
          color: Colors.blue,
          child: Text("启动相机"),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_scanner: ^0.1.5

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_scanner/flutter_scanner.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
48
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
74
Learn more about scoring.

We analyzed this package on Mar 27, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test