scan_view 0.0.6 copy "scan_view: ^0.0.6" to clipboard
scan_view: ^0.0.6 copied to clipboard

A new Flutter plugin.

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();
  }
}
0
likes
20
pub points
0%
popularity

Publisher

unverified uploader

A new Flutter plugin.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on scan_view