scan_view 0.0.6

  • Readme
  • Changelog
  • Example
  • Installing
  • 67

scan_view #

A new Flutter plugin.

Getting Started #

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

demo #

ScanView为可全屏大取景框(取景框为正方形居中,宽高为宽度的60%)

SmallScanView为窄框取景(取景框为长方形居中,宽为宽度的60%、高度176写死了,有需要变更的自行修改源码)

ScanViewController和SmallScanViewController有六个方法

setTorchOn()//手电筒开

setTorchOff()//手电筒关

setScanResume()//恢复扫码

setScanPause()//暂停扫码

setShowViewFinder()//显示取景框

setHideViewFinder() //隐藏取景框

setScanClose()//关闭扫码

setScanOpen() //开启扫码

例子:

class DemoExample extends StatelessWidget {

SmallScanViewController smallScanViewController;

var context;

@override

Widget build(BuildContext context) {

this.context = context;

return Scaffold(

    appBar: AppBar(title: const Text('Flutter TextView example')),
    
    body: Column(children: [
    
      Center(
      
          child: Container(
          
              width: 480.0,
              
              height: 176.0,

              child: SmallScanView(
              
                onSmallScanViewCreated: _onSmallScanViewCreated,
                
                onSmallScanViewScanResult: _setScanResult,
                
              )
              
          )
          
      ),
      
      Expanded(
      
          flex: 3,
          
          child: Container(
          
              color: Colors.blue[100],
              
              child: Center(child: RaisedButton(onPressed: _doTorch, child: Text("手电"))))),
              
    ]));
    

}

var open = false;

void _doTorch() {

if(open){

  open = false;

  this.smallScanViewController.setTorchOff();
  
}else{

  open = true;

  this.smallScanViewController.setTorchOn();
  
}

}

void _setScanResult(String str){

this.smallScanViewController.setScanPause();

showDialog(

    context: this.context,
    
    builder: (context) {
    
      return new AlertDialog(
      
        title: new Text("提示"),
        
        content: new Text(str),
        
        actions: <Widget>[
        
          new FlatButton(
          
            onPressed: () {
            
              Navigator.of(context).pop();
              
            },
            
            child: new Text("确认"),
            
          ),
          
        ],
        
      );
      
    });
    

}

void _onSmallScanViewCreated(SmallScanViewController controller) {

this.smallScanViewController = controller;

this.smallScanViewController.setScanOpen();

}

}

0.0.3 #

  • fix bug

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:scan_view/scan_view.dart';
import 'package:scan_view/small_scan_view.dart';

void main() => runApp(MaterialApp(home: TextViewExample()));

class TextViewExample extends StatelessWidget {
//  ScanViewController scanViewController;
  SmallScanViewController smallScanViewController;
  var context;
  @override
  Widget build(BuildContext context) {
    this.context = context;
    return Scaffold(
        appBar: AppBar(title: const Text('Flutter TextView example')),
        body: Column(children: [
          Center(
              child: Container(
                  width: 480.0,
                  height: 176.0,
//                  child: ScanView(
//                    onScanViewCreated: _onScanViewCreated,
//                    onScanViewScanResult: _setScanResult,
//                  )
                  child: SmallScanView(
                    onSmallScanViewCreated: _onSmallScanViewCreated,
                    onSmallScanViewScanResult: _setScanResult,
                  )
              )
          ),
          Expanded(
              flex: 3,
              child: Container(
                  color: Colors.blue[100],
                  child: Center(child: RaisedButton(onPressed: _doTorch, child: Text("手电"))))),

        ]));
  }

  var open = false;
  void _doTorch() {
    if(open){
      open = false;
//      this.scanViewController.setTorchOff();
      this.smallScanViewController.setTorchOff();
    }else{
      open = true;
//      this.scanViewController.setTorchOn();
      this.smallScanViewController.setTorchOn();
    }
  }

  void _setScanResult(String str){
    showDialog(
        context: this.context,
        builder: (context) {
          return new AlertDialog(
            title: new Text("提示"),
            content: new Text(str),
            actions: <Widget>[
              new FlatButton(
                onPressed: () {
                  Navigator.of(context).pop();
                },
                child: new Text("确认"),
              ),
            ],
          );
        });

  }

//  void _onScanViewCreated(ScanViewController controller) {
//    this.scanViewController = controller;
//    this.scanViewController.setResume();
//  }

  void _onSmallScanViewCreated(SmallScanViewController controller) {
    this.smallScanViewController = controller;
    this.smallScanViewController.setScanResume();
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  scan_view: ^0.0.6

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:scan_view/scan_view.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
47
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
67
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:scan_view/scan_view.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:scan_view/scan_view.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:scan_view/scan_view.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:scan_view/scan_view.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [scan_view] that is in a package requiring null.

Health suggestions

Fix lib/small_scan_view.dart. (-1 points)

Analysis of lib/small_scan_view.dart reported 2 hints:

line 2 col 8: Unused import: 'dart:async'.

line 57 col 40: This function has a return type of 'Future

Fix lib/scan_view.dart. (-0.50 points)

Analysis of lib/scan_view.dart reported 1 hint:

line 56 col 40: This function has a return type of 'Future

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

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